I scripted a teleportation script. How do I ensure that the sound effect plays only a single-time, when the part is being touched?
local TeleportPosition = game.Workspace.TeleportPosition
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") thenalways an Humanoid
if game:GetService("Players"):FindFirstChild(hit.Parent.Name) then
game:GetService("Players"):GetPlayerFromCharacter(hit.Parent).Character:WaitForChild("HumanoidRootPart").CFrame = TeleportPosition.CFrame
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.Workspace.teleporting:Play()
end
end)