Home > Blockchain >  Lua: Why the function didnt call?
Lua: Why the function didnt call?

Time:08-10

Okay I am coding in lua a cheat for Roblox (just for fun). But I created a function and the function got called! I used the Library Kavo UI for the window.

But... There is everything looks like in my code just that I change function() to combat()!

If I run this it doesn't show the UI! But if I delete the function and the section it shows!

How do I fix it?

local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/xHeptc/Kavo-UI-Library/main/source.lua"))()

local Window = Library.CreateLib("Ghoster", "Synapse")

local Combat = Window:NewTab("Combat")
local Movement = Window:NewTab("Movement")
local Exploit = Window:NewTab("Exploits")

local CombatSection = Combat:NewSection("Combat Options")
local MovementSection = Movement:NewSection("Movement Options")
local ExploitSection = Exploit:NewSection("Exploit Options")

function aimbot()
    loadstring(game:HttpGet(('https://gitlab.com/marsscripts/marsscripts/-/raw/master/CCAimbotV2'),true))()
end

CombatSection:NewButton("Aimbot", "Aims your enemies", aimbot()
    print("Loaded Aimbot")
end

CodePudding user response:

The problem lies in misunderstanding the following syntax:

CombatSection:NewButton("Aimbot", "Aims your enemies", function()
    print("Loaded Aimbot")
end

CombatSection:NewButton receives 3 arguments, "Aimbot", "Aims your enemies" and an anonymous function.

Just to ilustrate what you did, let's put that anonymous function into a variable instead:

local yourFunction = function()
    print("Loaded Aimbot")
end

And you changed that to (the invalid code)

local yourFunction = aimbot()
    print("Loaded Aimbot")
end

What you actually wanted is to pass aimbot as a function:

CombatSection:NewButton("Aimbot", "Aims your enemies", aimbot)

Or call aimbot from within that anomynous function:

CombatSection:NewButton("Aimbot", "Aims your enemies", function()
    aimbot()
    print("Loaded Aimbot")
end
  • Related