I'm trying to make for my door script, where when you come close to the door a sound plays, and a GUI pops up. I got everything working, however I cannot get this to work.
I’ve noticed the issue is mainly that its probably playing then stopping immediately
I haven’t tried much solutions except adding a debounce or some other things.
Here is the local script, (I only want the sound to play for the client, that’s the reason.):
local mag2 = (Character.HumanoidRootPart.Position - Door.Center.Position).magnitude
if mag2 <= Door.Config.Range.Value then
if not played then
sound:Play()
wait(0.1)
played = true
if played == true then
sound:Stop()
played = false
end
end
end

1 comment
If none of these configurations are fixing your issue, it may be a problem with your mathematics.