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

How would I make GUI Text change when a brick is clicked?

Asked by 4 years ago

I'm new to scripting, so I'm not very good at this. I made this code out of what I do know about scripting, but it won't work.

function onClicked(mouse)
    game.StarterGui.ScreenGui.TextButton.Text = "hi"
    wait(5)
    game.StarterGui.ScreenGui.TextButton.Text = "x"
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I'm not sure what's wrong with it, can soemone help me?

0
Do you want the UI to change for everyone, or just the person who clicked it? mc3334 649 — 4y

1 answer

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
4 years ago

Hello! To do this, we will need something called a remote event. Just follow the following steps:

SETUP:

1)Create a remote event under ReplicatedStorage

-Name it "Clicked"

2)Create a local script under the text label you want to change.

4)Create a click detector under the part you want to get clicked

3)Create a server script under the part you want to to get clicked

SCRIPTING

SERVER SCRIPT:

EV = game:GetService("ReplicatedStorage"):WaitForChild("Clicked")

script.Parent.ClickDetector.MouseClick:Connect(function()
    EV:FireAllClients()
end)

LOCAL SCRIPT:

EV = game:GetService("ReplicatedStorage"):WaitForChild("Clicked")

EV.OnClientEvent:Connect(function()
    script.Parent.Text = "hi"
    wait(5)
    script.Parent.Text = "x"
end)

I hope this helps. With further questions/comments/concerns, feel free to reply to my post. ~mc3334

Ad

Answer this question