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

Why is this client event Script not firing my event?

Asked by 3 years ago
Edited by Ziffixture 3 years ago

I am trying to fire a remote event when a player touched my block. Here is the code:


local guieventsfolder = game.ReplicatedStorage.GuiEvents
local mapevent = guieventsfolder.WinsEvent
local levelsevent = guieventsfolder.LevelsEvent


local bathroombeginningsensor = game.Workspace.Bathroom.Checkpointbathroomfirst

bathroombeginningsensor.Touched:Connect(function(plr)
    mapevent:FireClient(plr,mapevent)
    winsevent:FireClient(plr,winsevent)
    levelsevent:FireClient(plr,levelsevent)

It keeps saying: FireClient:player argument must be a Player object.

Ps:I never really grasped what the second argument is for.please explain. I know the first parameter is the player, but i don't know what the second one is for.

0
The second argument is variadic, whatever you continue to pass will be sent to the respective Player, and received via your 'OnClientEvent' callback either in the form of a variadic or positional parameter(s). Ziffixture 6913 — 3y
0
The Player Object is what is used to represent the connected Client. As it works in the real world, you require to know exactly who you're sending information to. In ROBLOX, as any individual TCP connection, this "individual" is a connected Client, you require this Instance specifically to illustrate who you're sending that information to. Ziffixture 6913 — 3y
0
If you read the documentation to 'Touched', you would know it provides the BasePart that made contact with the respective BasePart, not a Player Instance, you must filter that out. Ziffixture 6913 — 3y
0
What are you trying to send anyways? Players char? xXLegendGamerz16Xx 231 — 3y

Answer this question