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

Team Script Won't Work?

Earlier today I decided to go ahead and develop my Fort a bit more. Then while making my Team Gui script I came across an issue. It didn't work.

Player = game.Players.LocalPlayer
TeamGui = Player.PlayerGui.TeamChange
Xotac = TeamGui.XotacLegion
Raiders = TeamGui.Raiders

Xotac.MouseButton1Down:connect(function()
	Player.TeamColor = TeamColor.new("Cyan")
	Player.Character.Humanoid.Health = 0
end)

Raiders.MouseButton1Down:connect(function()
	Player.TeamColor = TeamColor.new("Bright red")
	Player.Character.Humanoid.Health = 0
end)

Output:

17:41:28.477 - ServerScriptService.TeamScript:2: attempt to index global 'Player' (a nil value) 17:41:28.478 - Stack Begin 17:41:28.478 - Script 'ServerScriptService.TeamScript', Line 2 17:41:28.479 - Stack End 17:42:44.277 - Auto-Saving...

2 comments

0

Is this in a script or a LocalScript?

0

No

1 answer

It looks to me like you're using LocalPlayer in a server-sided script, which will always return nil.

You can only use Game.Players.LocalPlayer in a LocalScript.

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