Im trying to make the music turn on and off (currently testing). I can't see a problem. Help.
01 | script.Parent.MouseButton 1 Click:Connect( function () |
02 | if script.Parent.Value.Value = = '1' then |
03 | script.Parent.Parent.Parent.Parent.On.TextLabel.Text = 'Off' |
04 | script.Parent.Value.Value = '0' |
05 | end |
06 | if script.Parent.Value.Value = = '0' then |
07 | script.Parent.Parent.Parent.Parent.On.TextLabel.Text = 'On' |
08 | script.Parent.Value.Value = '1' |
09 | end |
10 | end ) |
You should probably use something like this
01 | local on = true |
02 | script.Parent.MouseButton 1 Click:Connect( function () |
03 | if on = = true then |
04 | script.Parent.Parent.Parent.Parent.On.TextLabel.Text = 'Off' |
05 | on = false |
06 | elseif on = = false then |
07 | script.Parent.Parent.Parent.Parent.On.TextLabel.Text = 'On' |
08 | on = true |
09 | end |
10 | end ) |
Sorry if this don't work, but it looks like it should for what you're trying to accomplish.
01 | local ToggleValue = script.Parent:WaitForChild( 'Value' ) -- Looking for the value object |
02 |
03 | script.Parent.MouseButton 1 Click:Connect( function () -- Click function |
04 | ToggleValue.Value = not ToggleValue.Value -- Alternates the value between true and false |
05 |
06 | if ToggleValue.Value then -- If ToggleValue is true... |
07 | script.Parent.Parent.Parent.Parent.On.TextLabel.Text = 'Off' |
08 | else -- If ToggleValue isn't true... |
09 | script.Parent.Parent.Parent.Parent.On.TextLabel.Text = 'On' |
10 | end |
11 | end ) |