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

How to make a soundtrack play when a player steps on a block?

I have it so when the player first starts the game they are given a soundtrack, but I'd like it that when they'd enter a certain area and touch an invisible block it would change the music. How would I go about this?

1 answer

I'm assuming the sound is in their PlayerGui to make it so they can hear it only.

script.Parent.Touched:connect(function(hit)
if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
p = game.Players:GetPlayerFromCharacter(hit.Parent)
game.Workspace.SoundYouWantToStop:Stop()
game.Workspace.SoundYouWantToPlay:Play()
end
end)

2 comments

0

Since it is a one player server I've put it in the workspace, how would I do it if the sound was in workspace?

0

It's the same thing. For lines 4 and 5, redefine the paths. I'll do it.

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