Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there alternative way to a localplayer?

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?

1 comment

0

Is the ServerScript the one that is firing the RemoteEvent, or is it the one that is receiving it from a LocalScript?

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.