Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would you make sound come from a different block?

Asked by
enboh 2
4 years ago

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

0
the part i want to be playing the sound from is named "Playing" enboh 2 — 4y

1 answer

Log in to vote
0
Answered by
Raccoonyz 1092 Donator Moderation Voter
4 years ago
Edited 4 years ago

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.

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? enboh 2 — 4y
Ad

Answer this question