So I made a short script so you get a certain GUI when you join the game. But I get this error.
12:26:04.771 - Workspace.HandToHandle:4: attempt to index local 'User' (a nil value)
12:26:04.772 - Stack Begin
12:26:04.772 - Script 'Workspace.HandToHandle', Line 4
12:26:04.773 - Stack End
And my script is:
game.Players.PlayerAdded:Connect(function(plr) local Players = game:GetService("Players") local User = Players:FindFirstChild(plr) local UserGUI = User:FindFirstChild("PlayerGui") local Handto = script.Handtoui:Clone(UserGUI) end)
No errors in the script so I don't know what I did wrong here.
FindFirstChild() only takes strings as arguments.
Therefore, on line 3, change local User = Players:FindFirstChild(plr)
to local User = Players:FindFirstChild(plr.Name)
.
plr is already defined as the local player so therefore u dont need to access the players again, u can just do this
local User = plr