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

How would you make sound come from a different block?

I have a sound block that plays when you click it, but I want the sound to come from a different block because the click block is getting deleted. I've tried:

local move = script.Parent.Parent:WaitForChild("Playing")
Brick = script.Parent
Sound = Brick.NANI

function onClicked()
wait(2.9)
Sound:Play()
end

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

I know this is incorrect

1 comment

0

the part i want to be playing the sound from is named "Playing"

1 answer

There are a few things you'll need to do in order to change the sound.

First off, don't use :WaitForChild(). Using :WaitForChild() constantly is a bad habit to get into.

Secondly, in order to make the sound come from a new block, you'll need to go to the workspace.

An example is below.

local sound = game.Workspace.Playing.Sound

In order to use this with your current script, you could do:

local sound = game.Workspace.Playing.Sound

function onClicked()
wait(2.9)
Sound:Play()
end

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

You actually did a pretty good job at making a script.

Good luck in whatever you want to make.

PS: If this doesn't work, leave a comment.

1 comment

0

doesnt work, but i have a few questions. where should i put the sound i want to play? it says local sound in the first line but the 5th line says Sound. Is that correct?

This discussion is preserved as it was. New answers, comments, and votes are closed.