✓ Accepted answer
Hello GamingHDstudios.
Your issue is a simple fix.
You can make a Touched function and get the hit.Parent, and check if the hit.Parent is a Humanoid or Player using the code below.
if hit.Parent:FindFirstChild("Humanoid")
And then play the Sound. This is simply done using the function, Play().
It would be done in terms like this.
workspace.Sound:Play()
Now that was an example, your Sound might be a different name.
Also it is recommended to use workspace instead of game.Workspace as it takes less lines of code and is more clean.
So now that we've made the first Part's Script, let's make the second's.
In our other Part we'll do the same thing, which is.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
workspace.Sound:Play()
end
end)
But instead, we'll change the Play() function to a Stop() function, stopping the music being played.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
workspace.Sound:Stop()
end
end)
Hopefully this has helped.
If this has helped you or somebody else you know, click 'Accept Answer'.
2 comments
if not workspace:FindFirstChild("SOUND NAME") then (clone script) end
Confused on what you're asking, can you clarify -- also, don't set parents from Instance.new().