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

Why does my local script not carry out the function in a remote event?

Asked by 5 years ago

I have a script which would fire a remote event to a specific player like this:

game.ReplicatedStorage.ExpChanged:FireClient(player)
-- player is the variable which represents the specific client to fire and ExpChanged is the remote event

And the function to be ran in a local script when the event fires is this:

game.ReplicatedStorage.ExpChanged.OnClientEvent:Connect(function() print("Random code here") end)

For some weird reason, the script fires the event without causing any errors, and yet my local script doesn't seem to be carrying out the function. What am I doing wrong??

0
I'm sure you would fire the event vice versa? I think the local script should do :FireClient. I'm not sure, look up how to fire an event from server to client, because I think that's the wrong way to do it, haven't tried myself. BiIinear 104 — 5y
0
Maybe your local script wasn't loaded yet by the time the event was fired. It could also be the fact you are not referencing 'ReplicatedStorage' using the standard 'game:GetService()' method but rather by using the dot operator. Le_Teapots 913 — 5y
0
Bilinear I'm pretty sure that's how the event is supposed to be fired. tiraner300 I can confirm that the local script finished loading before the event was fired, and after I replaced game.ReplicatedStorage with game:GetService("ReplicatedStorage"), it still has no effect. ServerLover38 21 — 5y
0
Oops, sorry! I figured it out, it wasn't the local script that couldn't listen for the event (well, it was, but for a different reason). Apparently some other code written before the event coding for the local script was yielding, and so the local script couldn't carry out the function, so I'm gonna have to fix the bugs for code I written earlier than the code for the event! ServerLover38 21 — 5y

Answer this question