Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Team Script Won't Work?

Asked by 10 years ago

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...

0
Is this in a script or a LocalScript? emite1000 335 — 10y
0
No BosswalrusTheCoder 88 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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.

Ad

Answer this question