Local player a nil value?
Asked by
5 years ago Edited 5 years ago
I made two scripts and they both don't work.In the output it says for both of them: "attempt to index 'plr' (a nil value)". Could anyone please help point out the problem.
Here are both of the scripts:
01 | local plr = game:GetService( "Players" ).LocalPlayer |
02 | local Character = plr.Character or plr.CharacterAdded:Wait() |
03 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
04 | local vr = game.StarterGui.ScreenGui.Frame.RedPlayer.RedPlayerScore.RedValue |
05 | local vb = game.StarterGui.ScreenGui.Frame.BluePlayer.BluePlayerScore.BlueValue |
07 | Humanoid.Died:Connect( function () |
08 | if plr.TeamColor = = BrickColor.new( "Bright blue" ) then |
Second one:
01 | local plr = game.Players.LocalPlayer |
02 | local f = game.StarterGui.ScreenGui.Frame |
03 | local rn = f.RedPlayer.RedPlayerName |
04 | local bn = f.BluePlayer.BluePlayerName |
06 | if plr.TeamColor = = BrickColor.new( "Bright blue" ) then |
Thank you for trying to help. I appreciate it very much.