I made it so, when you touch a part, a sound plays and loops until another part is touched, but don't worry about the other part, the problem is at the music playing part.
I wrote a successful script that works but it plays in a kind of "round" where it overlaps. Let me try and explain: You hear the first note of the song and then half a second later you hear it again. The song plays about 20 or so times when you walk over the block.
Can anyone make it so that all other duplicates are destroyed or maybe an alternative to help?
Here is the script:
local part = script.Parent
part.Touched:connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
wait(1)
local part2 = Instance.new("Part")
part2.Name = "MusicPlayerOne"
part2.Parent = game.Workspace
part2.Transparency = 1
part2.CanCollide = false
part2.Anchored = true
part2.Position = Vector3.new(-51.3, 15.5, -19.1)
wait(1)
local sound = Instance.new("Sound")
sound.Parent = part2
sound.Looped = true
sound.Playing = true
sound.Volume = 1
sound.SoundId = "rbxassetid://178276804"
wait(1)
end
end)
