Hi, i was running a script to fire event if player have 100 calls in leadstats. plrs = game:WaitForChild("Players")
1 plrs = game:WaitForChild("Players") 2 plr = plrs.LocalPlayer 3 4 if plr.leadstats.Calls.Value == 99 then 5 6 7 game.ReplicatedStorage.StrengthEvent.OnServerEvent:Connect(function(player) 9 player.PlayerGui.Notification.Event:Fire("New level!") 10 11 end) 12 end
Output
13:00:19.592 - ServerScriptService.LevelNotifications:4: attempt to index global 'plr' (a nil value) 13:00:19.592 - Stack Begin 13:00:19.593 - Script 'ServerScriptService.LevelNotifications', Line 4 13:00:19.593 - Stack End
How to fix it? (I'm n00b at scripts xd)
Hence the name, the LocalPlayer is only available in local scripts. It contains a reference to the local player, or client, hence why it only works in local scripts. There's only 1 server per game that contains all the players in the game, which is why LocalPlayer is nil on the server. You'll have to use different means to get the player you want.