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

Is there alternative way to a localplayer?

Asked by
c5or 8
6 years ago

So, I have a RemoteEvent in ReplicatedStorage, which was created by a serverscript, but I need to get the player's teamcolor. But since I can't use LocalPlayer, is there anyway to declare a localplayer in a serverscript?

0
Is the ServerScript the one that is firing the RemoteEvent, or is it the one that is receiving it from a LocalScript? cowsoncows 951 — 6y

1 answer

Log in to vote
1
Answered by
Mineloxer 187
6 years ago

Since the Script belongs to the server, there can't be a local player. But when clients fire remote events. The first argument is the player who fired it. If I understand your question correctly, that should be what you need.

local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

remote.OnServerEvent:Connect(function(player, otherArguments)
    --Works fine
    print(player.Name .. " has fired an event!")
end)
Ad

Answer this question