I created a text label for my settings and i put text is on i want when i click it says on to off and it stops like music or stuff and when i click again it says on and turn on music or something else
✓ ANSWER ACCEPTED
(ANSWERED) I want player to click to change it to on and off but why isn't it working?
2 answers
✓ Accepted answer
Put the local script in a text button, not text label
script.Parent.Text = "Music: On"
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Text == "Music: On" then
script.Parent.Text = "Music: Off"
elseif script.Parent.Text == "Music: Off" then
script.Parent.Text = "Music: On"
end
end)
Alternative option
local Switch = true
local OnText = "Music: On"
local OffText = "Music: Off"
script.Parent.Text = OnText
script.Parent.MouseButton1Click:Connect(function()
-- ternary; shortened if statement
script.Parent.Text = (Switch and OffText or OnText)
-- make switch opposite of what it is
Switch = not Switch
end)
3 comments
0
Thanks Azarth
0
That would work, nice job
0
That would work, nice job
This discussion is preserved as it was. New answers, comments, and votes are closed.

27 comments
hi raid6n the other question was closed i tried doing that but it didn't work
What’s the output?
I edited try now
wait imma get it
alr brother
thanks
it says Expected identifier when parsing expression,got then
What line
line 10
10? Only 8 lines
I’ll test in studio brb
ok ty
Does the script work?
Because it works for me.This means you have another script that doesn’t work can you click on the output and tell me what the output defects you to
it dosen't because the line 10 where it says speed <8 then is making everything not working
that’s a different script
can you put the script you used in the answer place
I used the same script
where did you put it in ?
i put it in serverscriptservice in a script
It’s suppose to be inside the button
what question are you asking im asking about this one "i want player to lose stats like coins when running"
ohhh
yea it still didn't work it was closed lol
fixed
still didn
sorry i had to go because of some problem