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

Why won't this server event trigger?

Asked by 6 years ago

Both these scripts and the Remote Event are inside a Text Button

local script

local button = script.Parent
local callEvent = script.Parent:FindFirstChild("CallAnimal")

local function onButtonActivated()
    print("Requesting call")
    callEvent:FireServer()
    print("Call Sent")
end

button.Activated:Connect(onButtonActivated)

normal script

local function callAnimal(player)
        print("Who called?")    
end

script.Parent.CallAnimal.OnServerEvent:Connect(callAnimal)

All the script is printing is the

Requesting Call

Call Sent

Nothing is printing from the normal script (meaning the event isn't firing)

0
-insert triggered meme here- LoganboyInCO 150 — 6y

1 answer

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

You should put your RemoteEvents in ReplicatedStorage if you want multiple clients and a single server script to use them. Your problem is almost certainly that you have the RemoteEvent object as a child of something in StarterGui, so when the GUI is cloned onto the player instances, a new instance of the RemoteEvent is created for each player. RemoteEvents are not passed from client to server by name, the client and server have to be using the same replicated instance of the RemoteEvent object. So... as far as your server script is concerned, no one is firing the event it connected a listener to. However, each client is firing a RemoteEvent that the server is clueless about, and which will (over time) cause errors to spew in your server logs that say something to the effects of "RemoteEvent queue exhausted, did you forget to implement OnServerEvent?"

Ad

Answer this question