I am trying to implement a debounce system on a piece of code wich either makes the player switch control over the body of the target (playerr) or the other way around. The first time it runs it runs fine and only once but it breaks the second time for apparently no reason.The incontrol value is fine how ever the script runs alot of times even though i implemented a debounce system. fired5 also doesnt print
local debouncenr9k = false
player.statsleader.incontrol.Changed:Connect(function()
if debouncenr9k == false then
debouncenr9k = true
print("Fired6")
if player.statsleader.incontrol.Value == true then
print("Fired")
game.ReplicatedStorage.switchungain:FireClient(playerr)
game.ReplicatedStorage.unfinger:FireClient(player)
repeat
if player.statsleader.ether.Value >= 1 then
print("Fired2")
player.statsleader.ether.Value = player.statsleader.ether.Value - playerr.statsleader.ether.Value/100
wait(0.4)
player.statsleader.etherregen.Value = false
else
player.statsleader.incontrol.Value = false
print("Fired3")
end
until player.statsleader.incontrol.Value == false
print("Fired4")
else
print("Fired5")
wait()
game.ReplicatedStorage.switchungain:FireClient(player)
game.ReplicatedStorage.unfinger:FireClient(playerr)
wait(1)
player.statsleader.etherregen.Value = true
char.Humanoid.PlatformStand = true
print(char.Humanoid.PlatformStand)
wait()
debouncenr9k = false
end
end
end)