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

How to get a player object for a remote event?

I have this script in a textbutton which is in a surface gui.

local button = script.Parent
local internet = game.StarterGui.Screen.Internet
local InternetSender = game.ReplicatedStorage.RemoteFunctions.Screen:FindFirstChild("InternetOn")
local player = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()
	InternetSender:FireClient(player)
end)

I'm trying to make the script send a signal to a local script using the remote event but when I run it I get an error saying player argument must be a player object. How do you get the player object?

1 comment

0

You have to use FireServer, which goes from Client to Server. https://scriptinghelpers.org/questions/94651/can-someone-help-me-understand-remote-events-they-dont-work-for-me#87427 | This post will help you understand RemoteEvents

1 answer

I think there are two problems here: 1.) LocalPlayer can only be accessed with a LocalScript, therefore the :FireClient(player) would be firing nil. 2.) If you're using a LocalScript, :FireClient() can only be accessed with a ServerScript, so it would not work.

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