Hello, I've tried making this script for a few days and I'm starting to give up. I want a specific sound play from Part1 when part 2 Is hit then it should repeat until part 3 is hit
cooldown = 0 script.Parent.Touched:Connect(function(hit) if hit.Parent.Testblock.Name == "Testblock" and cooldown == 0 then cooldown = 1 game.workspace.dontwalk:FindFirstChild("Soundplayer").Sound:Play() wait(game.workspace.dontwalk.Sound.TimeLength) cooldown = 0 end end)
Any help would be appreciated nothing works cause I f***** it up xd
Add this inside the Touched function.
function = local function(Give,x) instance.new("leaderstats") instance.parent = x end Give(game.Players.Player1,1)
I believe this should work for what you're trying to do (explanations are in the script) if you think this was helpful please mark this post answered so that you and I can get points
--put this script in part2 local Part1 = workspace.Part1 local Part2 = script.Parent local Part3 = workspace.Part3 -- define parts local debounce = false local Sound = Instance.new("Sound") -- creating a new sound instance Sound.Parent = Part1 -- put the sound in the part you want the sound to come from Sound.Volume = 3 -- volume Sound.Looped = true -- sound is now looped Sound.SoundId = ("rbxassetid://4636014874") -- define soundId Part2.Touched:Connect(function() -- touched event if debounce == false then -- debounce so it will only set the timeposition to 0 once debounce = true Sound.TimePosition = 0 -- makes the sound start from the beginning when you touch part2 (remove this if you want it to start from where it ended) Sound.Playing = true -- sound starts to play end end) Part3.Touched:Connect(function() Sound.Playing = false -- sound stops playing debounce = false -- once you touch part3 the debounce will turn false so you can touch part2 again end)