Issues with Turn on/off Button on a Radio

I’m trying to make my radio have an off and on button but I’m getting errors.

Code for on button:

local Radio = script.Parent
local Click = Instance.new("ClickDetector",Radio)
Click.MouseClick:Connect(function(OnClick)
	Radio.Parent.Sound:Play()
end)

Code for off button:

local RadioPart = script.Parent
local Click = Instance.new("ClickDetector",RadioPart)
Click.MouseClick:Connect(function(OnClick)
	RadioPart.Parent.Sound:Stop()
end)

Error:

Model:

Can you show the stack (model) of the radio in the explorer and send the screenshot here?

Yep! I’ve just added an image of the model.

Should I add a screenshot of the music script I’m using as well?

On:

local Radio = script.Parent
local Click = Instance.new("ClickDetector",Radio)
Click.MouseClick:Connect(function(OnClick)
	Radio.Parent.Base.Sound:Play()
end)

Off:

local RadioPart = script.Parent
local Click = Instance.new("ClickDetector",RadioPart)
Click.MouseClick:Connect(function(OnClick)
	RadioPart.Parent.Base.Sound:Stop()
end)

Caused because Sound is in “Base”, not the radio model.

Well, if I don’t have the Sound in a part the music plays everywhere at one volume which I don’t want. Is there a way for this to work the way I’m doing it?

If you want a sound to come from a part it has to be parented or descended to a part. Only way.

So, I can’t use an on/off button with how I’m doing it?

:man_facepalming:, I could’ve just put the On/Off Buttons in the same part as the Sound and it works as intended. Sorry for wasting anytime!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.