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

Event Fired Clinet Parameter is Nil why???

Asked by 4 years ago
Edited 4 years ago

I cannot share the full script due to reasons, but I can tell about the following... I have this main script, a regular script in server script service, which picks a random part from the workspace and it fires to a client by.. Event:FireClient(Player, Part.Position). On the receiving end in another script, a local script in starter character scripts, it connects the function as such...

Event.OnClientEvent:Connect(function(Player, Location)
    Code Here, Not sharing due to reasons...
end)

My problem is that the Location otherwise Part.Position in this local script is nil why is this a nil value instead of the Vector3 Value???

**My spelling or some Syntax may be wrong, but that is the not issue here.

1 answer

Log in to vote
3
Answered by 4 years ago
Edited 4 years ago

OnClientEvent doesn't have a Player parameter as you can see here. You can get the player from just using game.Players.LocalPlayer since it's a local script. If you try printing 'Player' you'll notice that it will print the Vector3 Value, that's because the part's location is being assigned to 'Player' and 'Location' is going to remain nil because you aren't actually assigning anything to it.

0
Ahh that does make sense and Im sure your right but then why need to put player in Event:FireClient(Player, Part.Position)??? THUNDER_WOW 203 — 4y
1
FireClient will only fire to the specified client. That's why you need the Player in FireClient, because it needs to know which client it will be firing to. xInfinityBear 1777 — 4y
0
Alr, thx for the clarification. THUNDER_WOW 203 — 4y
Ad

Answer this question