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

Help with TextButton text changing when clicked (Using RemoteEvents)?

I am very new to using RemoteEvents and I need help. What I am trying to do is, when you click the textbutton, the text of it will change and all clients can see it.

ServerScript:

MakeText.OnServerEvent:connect(function(player, text)
	MakeText:FireAllClients(text)
end)

ClientScript:

Top.TextButton.MouseButton1Click:connect(function() -- Happens when you click the TextButton.
	MakeText:FireServer('I was clicked!')
end)

2 comments

0

Where is the remote event being stored in the gui?

0

Replicated Storage

1 answer

✓ Accepted answer

I presume your game has FE enabled?

You should make sure you give us your whole script. In your localscript, you say MakeText, so I assume that above there is a variable saying

local MakeText = game.ReplicatedStorage:WaitForChild("MakeText") -- Assuming MakeText is the name

This variable should be the same in both of your scripts, correct? Perhaps besides some hierarchy. Also, you should be using a RemoteEvent.

Assuming all the above is basically true, you're missing the part where you script actually does the part where the text is changed. You mainly need to edit your LocalScript to bellow.

Top.TextButton.MouseButton1Click:connect(function() -- Happens when you click the TextButton.
    MakeText:FireServer('I was clicked!')
end)

MakeText.OnClientEvent:connect(function(Text)
	Top.TextButton.Text = Text
end)

You never made the event that FireAllClients is going to well, fire.

If this helped, accept this answer! Any quesitons/problems? Just comment them

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