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

Remote Event runs fine in Local Play, but not while testing?

Asked by 6 years ago
Edited 6 years ago

I've always had problems with remote events, but now I'm really not sure what I did wrong.

Local script in the GUI

script.Parent.ChildAdded:Connect(function(tag)
    if tag:IsA("TextButton") then
        tag.MouseButton1Click:Connect(function()
            print("Clicked")
            game.ReplicatedStorage:WaitForChild("ChangeStage"):FireServer()
        end)
    end
end)

Server Script in ServerScriptService

game.ReplicatedStorage:WaitForChild("ChangeStage").OnServerEvent:Connect(function(player)
    print("Event Received")
end)

Remote Event called "ChangeStage" is in Replicated Storage. Again, it runs fine in Local Play, which doesn't make much sense to me because I don't know what about the FilteringEnabled is preventing the event from reaching the server while testing.

1 answer

Log in to vote
0
Answered by 6 years ago

Your code errors:

script.Parent.ChildAdded:Connect(function(child)
    if child:IsA("TextButton") then -- You're not only returning a textbutton. You're returning anything that inherits from it.
        child.MouseButton1Click:Connect(function() -- nope
        end) -- end) inside of an end?
    end-- Big no no
end)

No errors

cript.Parent.ChildAdded:Connect(function(child)
    if child.ClassName == "TextButton" then -- You're returning a textbutton. For a fact.
        child.MouseButton1Click:Wait() -- yup
    end -- Look at that. 
end)
0
Okay, but this doesn't address the remote event issue? You took the FireServer() line completely out, as well as the event listening for the mouse click the "No errors" code. Phantom1996 45 — 6y
0
i know i took out the fire server. And no i did not take out the event listening for the mouse click. User#19524 175 — 6y
0
How am I supposed to fire the server event then? Phantom1996 45 — 6y
Ad

Answer this question