function awarding(class, howmuch, Box) if Folder:FindFirstChild(Box) then print('found') if Folder:FindFirstChild(Box).Value == true then return function() class(howmuch) end end end end function money(amount, can) print('plz') plr:WaitForChild("Zeni").Value = plr.Zeni.Value + amount can = true end function power(amountt, cam) print("working?") plr:WaitForChild("Stats"):WaitForChild("Strength").Value = plr.Stats.Strength.Value + amountt print('strength+') cam = true end print('Functions') --VARIABLES plr = game.Players.LocalPlayer Input = script.Parent.Parent.CodeInput Enter = script.Parent Folder = plr:WaitForChild("Codes") --CODES codes = { ["Release!"] = awarding(money, 1000000, "Release"), ["Beta!"] = awarding(power, 5000000, "Beta"), ["ITS OVER 9000!!!"] = awarding(power, 9000, "ITS OVER 9000") } print('codes') Enter.MouseButton1Click:Connect(function() print('Clicked') local test = codes[Input.Text] if test then test() print('SENT')--doesn't print else print(':(')--prints :( end end)
I'm trying to add datastore. There's a script in serverscriptservice for this. If you need I'll gladly hand it.
Try fixing up your table.
//Disclaimer: I have not tested this yet and DO NOT know if it will work.
--CODES codes = { ["Release!"] = {Name = "Release", Money = 1000000}, ["Beta!"] = {Name = "Beta", Money = 5000000}, ["ITS OVER 9000!!!"] = { Name = "ITS OVER 9000", Money = 9000} }
Ya, I kinda messed up on the table, sorry about that. I'm just showing you the format.
**If this helped you, accept the answer, so we both can get reputation :) **
I think it's because of the weird way you made it call the functions.
Here's the way I did it:
Edit: fixed it i think
function awarding(class, howmuch, Box) if Folder:FindFirstChild(Box) then print('found') if Folder:FindFirstChild(Box).Value == true then return function() class(howmuch) end end end end function money(amount, can) print('plz') plr:WaitForChild("Zeni").Value = plr.Zeni.Value + amount can = true end function power(amountt, cam) print("working?") plr:WaitForChild("Stats"):WaitForChild("Strength").Value = plr.Stats.Strength.Value + amountt print('strength+') cam = true end print('Functions') --VARIABLES plr = game.Players.LocalPlayer Input = script.Parent.Parent.CodeInput Enter = script.Parent Folder = plr:WaitForChild("Codes") --CODES codes = { ["Release!"] = {awarding, money, 1000000, "Release"}, --change how it is as IIRC you can't store a function in a table and call it directly ["Beta!"] = {awarding, power, 5000000, "Beta"}, ["ITS OVER 9000!!!"] = {awarding, power, 9000, "ITS OVER 9000"} } print('codes') Enter.MouseButton1Click:Connect(function() print('Clicked') local test = codes[Input.Text] if test then test[1](test[2], test[3], test[4]) -- actually call the function from the first value print('SENT') else print(':(') end end)