Ah. Your issue is probably that this your code is running on the server. Only the client is able to utilize game.Player.LocalPlayer (hence the name)
Try making use of the Players.PlayerAdded() event.
Could you send the full code so that we can figure out how we are able to best define “player”?
eazoppe
(Eazoppe)
June 1, 2020, 10:57am
#24
I am testing another player function.
In that case, define player in a playerAdded event.
game.Players.PlayerAdded:Connect(function(plr)
remember to add an end)
at the bottom.
Definition of LocalPlayer
on server is nil, but on client for their own player. You’re supposed to use PlayerAdded
event and use the player argument.
1 Like
eazoppe
(Eazoppe)
June 1, 2020, 11:00am
#27
So with the new call function I did, I didn’t get any error and the code didn’t run meaning that it’s doing good so far.
Going on a alt to test out if it works for real.
Crrustyy
(boblox_man)
June 1, 2020, 11:04am
#28
You cannot call this from a server, and did you not say that it was inside a player added event?
eazoppe
(Eazoppe)
June 1, 2020, 11:05am
#29
So it has succeeded.
If any of you want to know what I did is change the plr which is local plr = game.Players.LocalPlayer
and changed it what I had before to summon ReplicatedStorage.GiveLightsaber.OnServerEvent:Connect(function(player, lightsaber)
and used Player which then made it work.