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

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

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)

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? sam147lordraven 0 — 10y
0
It's the same thing. For lines 4 and 5, redefine the paths. I'll do it. Shawnyg 4330 — 10y
Ad

Answer this question