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

How to get a player object for a remote event?

Asked by 4 years ago

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?

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 killerbrenden 1537 — 4y

1 answer

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

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.

Ad

Answer this question