my PvP script only work once, which means when I turn PvP on, I'm unable to turn it off, what is the error?
local player = game.Players.LocalPlayer if(player:WaitForChild("pvp", 2) == nil) then pvpEnabled = Instance.new("BoolValue") pvpEnabled.Name = "pvp" pvpEnabled.Parent = player pvpEnabled.Value = false else pvpEnabled = player.pvp pvpEnabled.Value = false end
local button = script.Parent.Frame.button local debounce = false function changePvp() if pvpEnabled.Value == false then if debounce == false then button.Text = "Enabled" debounce = true for i = 30,0,-1 do button.Text = i wait(1) if i == 0 then debounce = false button.Text = "Enabled" pvpEnabled.Value = true end end else if pvpEnabled == true then if debounce == false then button.Text = "Disabled" debounce = true for i = 30,0,-1 do button.Text = i wait(1) if i == 0 then debounce = false button.Text = "Disabled" pvpEnabled.Value = false end end end end end end end button.MouseButton1Down:connect(changePvp)