Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(Solved)Why does my car when I leave sound not turn off?

Asked by
brok4d 77
5 years ago
Edited 5 years ago

Hello, when I enter the car and get very light the second time I leave the car does not stop the fire and sound, it is like not entering the function to touch, does anyone know why? .

Car.PrimaryPart.Touched:Connect(function(touch)
    if touch.Parent:FindFirstChild('Humanoid') then
        fire.Enabled = true
        soundEngine:Play()
        soundEngine.Looped = true
        soundEngine.Volume = 1
        lucesd.Material = Enum.Material.Neon 
        while wheel1 and wheel2 do
            wait (0.05)
            local wlsp = ((wheel2.RotVelocity + wheel1.RotVelocity)/2).magnitude
            local wlsp2 = ((wlsp / 200) + idlespeed) * mult
            if wlsp2 < maxpitch then
                soundEngine.Pitch = wlsp2
            else
                soundEngine.Pitch = maxpitch
            end
        end     
    end
end)
Car.PrimaryPart.TouchEnded:Connect(function(touchEnd)
    if touchEnd.Parent ~= playerLocal then
        Ground.Touched:Connect(function(touch)
            if not debounce then
                debounce = true

                if touch.Parent:FindFirstChild('Humanoid') and touch.Parent.Name ~= "Enemy" then
                    soundEngine:Stop()
                    fire.Enabled = false

                end
                wait(2)
                debounce = false
            end

        end)
        Ground2.Touched:Connect(function(touch)
            if not debounce then
                debounce = true

                if touch.Parent:FindFirstChild('Humanoid') and touch.Parent.Name ~= "Enemy" then
                    soundEngine:Stop()
                    fire.Enabled = false

                end
                wait(2)
                debounce = false
            end

        end)
    end
end)
0
Have you tried using debounce and defining variables? rdkv 12 — 5y
0
Do you think it's because of the variable debounce? it is false by default. brok4d 77 — 5y
0
solved lower the wait () to 1 second instead of 2 and it works that nonsense hahahaha brok4d 77 — 5y
0
Thank you brok4d 77 — 5y

Answer this question