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

Error attempt to index nil with 'Name' ?

local deb = true 
script.Parent.Clicker.ClickDetector.MouseClick:connect(function(wat)
	if deb == true then
		deb = false
		local PlayerCash = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
		PlayerCash = PlayerCash + 15
		deb = true
	end
end)

I'm a beginner with lua and Roblox Studio so I don't know what to do.

1 answer

✓ Accepted answer

That is because from what I can see, player isn't defined, here is what I would do:

local deb = true

game:GetService("Players").PlayerAdded:Connect(function(player)
	script.Parent.Clicker.ClickDetector.MouseClick:connect(function(wat)
		if deb == true then
			deb = false
			local PlayerCash = game.ServerStorage.PlayerMoney:FindFirstChild(tostring(player.Name))
			PlayerCash = PlayerCash + 15
			deb = true
		end
	end)
end)

1 comment

0

Thank you, the error is gone.The money don't seem to change though. ( I am using Zednov's tycoon kit)

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