I want to make a push-up script that makes you go in-and out of the position by pressing j (An on and off switch basically) and I want it to switch each time between being on and off.
Currently it toggles it twice in a row.
Here’s currenty what I have in the local script.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PushUpsEvent = ReplicatedStorage:WaitForChild("PushUps")
local DoPushUpsEvent = ReplicatedStorage:WaitForChild("DoPushUps")
local EndPushUpsEvent = ReplicatedStorage:WaitForChild("EndPushUps")
local Mouse = game.Players.LocalPlayer:GetMouse()
local Debounce = false
local InPushUps = false
local InPushBool = false
Mouse.KeyDown:Connect(function(KeyCode)
if KeyCode == "j" then
if Debounce then return end
if Debounce == false then
Debounce = true
if not InPushBool then
print("Starting pushups")
PushUpsEvent:FireServer()
InPushUps = true
InPushBool = true
wait(1.5)
EndPushUpsEvent:FireServer()
InPushUps = false
InPushBool = false
Debounce = false
end
end
end
if InPushUps then
if KeyCode == "k" then
if Debounce == false then
Debounce = true
print("Doing Pushups")
DoPushUpsEvent:FireServer()
wait(1.5)
Debounce = false
end
end
end
end)