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

What do I fire a remoteEvent to?

Asked by 2 years ago

I'm making a survival game and I need to get it so when you chop down a tree you gain specific resources. I have everything done, except what you're supposed to fire it to. I need the event to fire the Client from the Server but don't know what to put in the parenthesis after "event:FireClient(?)". What do I need to do? I try things like "Player", or "Touched.Parent" or "Player.Name" but then it gives me any of these errors: "Unable to cast value to object", or "Argument must be a player object". Please help me :/

1 answer

Log in to vote
0
Answered by 2 years ago

event:FireClient(parameters)

You will need to make LocalScript and insert function event.OnClientEvent(parameters)

Parameters: you can use LocalPlayer or any parameter, but you will need to do the same for ServerScript. For example:

ServerScript:

-- The code I gave you in previous question or use your own
event:FireClient(player) -- You must connect to a function and insert event:FireClient() into the function. Make sure you add player if possible in the function as a parameter.

LocalScript:

-- Also use same code
function onClientEvent(player)
    -- do stuff
end
event.OnClientEvent:Connect(onClientEvent)

That was one example. You can search up RemoteEvent:FireClient() on Google and read more about it. Hope this helps!

0
When I do this, it yells at me that the parameter must by a player object, and when I put something else like player.Character of player.Name or whatever, it just says "Attempt to index nil with 'Character/Name'" AbettrWesley 6 — 2y
0
for player.Character use player.CharacterAdded:Wait() or something GamerLighting23233 63 — 2y
Ad

Answer this question