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

(ANSWERED) I want player to click to change it to on and off but why isn't it working?

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

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)

27 comments

0

hi raid6n the other question was closed i tried doing that but it didn't work

0

What’s the output?

0

I edited try now

0

wait imma get it

0

alr brother

0

thanks

0

it says Expected identifier when parsing expression,got then

0

What line

0

line 10

0

10? Only 8 lines

0

I’ll test in studio brb

0

ok ty

0

Does the script work?

0

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

0

it dosen't because the line 10 where it says speed <8 then is making everything not working

0

that’s a different script

0

can you put the script you used in the answer place

0

I used the same script

0

where did you put it in ?

0

i put it in serverscriptservice in a script

0

It’s suppose to be inside the button

0

what question are you asking im asking about this one "i want player to lose stats like coins when running"

0

ohhh

0

yea it still didn't work it was closed lol

0

fixed

0

still didn

0

sorry i had to go because of some problem

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.