Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

3 comments

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.

0

i know i took out the fire server. And no i did not take out the event listening for the mouse click.

0

How am I supposed to fire the server event then?

This discussion is preserved as it was. New answers, comments, and votes are closed.