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

Error: Attempt to index a nil value?

title is my error, what is wrong? it says its something in line 3...

game:GetService("Players").PlayerAdded:Connect(function(player)
	local Como = player.PlayerGui:FindFirstChild("Password")
	Como.Enabled = true
	game.Lighting.Blur.Enabled = true
	local Hobo = player.Character:FindFirstChild("Humanoid")
	Hobo.WalkSpeed = 0
end)

1 answer

Instance:FindFirstChild() returns the instance with the provided name if it exists, or otherwise returns nil. In your case, your call is redundant because you do not check if it returned nil.

GUIs cloned client-side won't replicate to the server (i.e. cloned from game.StarterGui), so the server was unable to find your GUI.

Player.Character is not loaded when game.Players.PlayerAdded fires, try the Player.CharacterAdded event like so:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		-- code
	end)
end)

2 comments

0

Thanks i already fixed it!

0

jesus christ I could've sworn you were at 78 points 1 month ago what

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