I made this code for twitter where if they type in the code 'code' they receive +10 Tokens. My script is not functioning right it doesn't give the player any Tokens. Now I am new to scripting, and I taught myself and I have recently taught myself properties like making a block transparent and cancollide on click, but I have trouble on these types of scripts! Please Help! I used a Local Script. The Output says: Players.Player1.PlayerGui.TwitterCodesGui.Submit.LocalScript:3: attempt to index local 'click' (a nil value) 14:27:07.734 - Stack Begin What is the problem in line 3? local stats = click:findFirstChild('leaderstats')
script.Parent.MouseButton1Click:connect(function(click)
if script.Parent.Parent.Input.Text == 'Code' then
local stats = click:findFirstChild('leaderstats')
if stats ~= nil then --If moneyholder exists then
local Tokens = stats:findFirstChild("Tokens") --Get money
Tokens.Value = Tokens.Value + 10
script.Parent.Parent.Input.Text = 'Me'
script.Parent.Text = 'Success!'
wait(1)
script.Parent.Text = 'Submit'
else
script.Parent.Parent.Input.Text = ''
script.Parent.Text = 'Invalid Code!'
wait(1)
script.Parent.Text = 'Submit'
end
end
end)

3 comments
The MouseButton1Click event doesn't pass any arguments to its listeners, so
clickis nil. Maybe replace it withscript.Parent?http://wiki.roblox.com/index.php?title=API:Class/GuiButton/MouseButton1Click
MouseButton1Click Doesn't return the function, so the click will do nothing