Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Very confused on this error? Attempt To Index Nil With 'Value'

20:13:25.447 - Workspace.Tycoon1.CashModule.Button.ClickDetector.CashCollect:5: attempt to index nil with 'Value'

local cash = game.Workspace.Tycoon1.CashModule.Screen.Cash.Value
local button = script.Parent

button.MouseClick:Connect(function(plr)
	plr:WaitForChild('Cash', 2).Value = cash
	cash.Value = 0
end)

1 answer

Heya, so you already defined .Value in the variable and you are defining it again in the MouseClick event. So just change that up and it should get rid of the error.

local cash = game.Workspace.Tycoon1.CashModule.Screen.Cash
local button = script.Parent
 
button.MouseClick:Connect(function(plr)
    plr:WaitForChild('Cash', 2).Value = cash.Value
    cash.Value = 0
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.