I am in production of an obby based experience and within the experience there are checkpoints. What I tried to produce is that everytime when a player reaches the next checkpoint, it plays an audio.
The way my script is set is so that the audio plays when the checkpoint is touched and then it has a 60 second cooldown. (Although I’d prefer it to work in a way that everytime a checkpoint is touched by a player for the first time, it plays the audio rather than it playing every 60 seconds that it’s touched)
After some short testing, I have realised that if one player stepped on the checkpoint than the next player to touch the checkpoint will not hear the audio.
How do I make it so that the script only applies to players individually and that if one player touched it, the cooldown would only apply to that player rather than it applying to everyone?
Here is the script in question:
local Played = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and Played == false then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Sound = game.Workspace.Sounds.Sound:Clone()
Sound.Parent = Player.PlayerGui
Sound:Play()
Played = true
wait(60)
Played = false
end
end)