I have made a push-up script that playing when you press J, however, it does it instantly without getting into the pushup position first (so you could do pushups from there), like a plank type of position.
My goal is to make it a two-step type of pushup system where you first where you first have to get into the position and then do the pushups
Local Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PushUpsEvent = ReplicatedStorage:WaitForChild("PushUps")
local DoPushUpsEvent = ReplicatedStorage:WaitForChild("DoPushUps")
local Mouse = game.Players.LocalPlayer:GetMouse()
local Debounce = false
Mouse.KeyDown:Connect(function(KeyCode)
if KeyCode == "j" then
if Debounce == false then
Debounce = true
print("Beginning Pushups")
PushUpsEvent:FireServer()
wait(1.5)
Debounce = false
end
if KeyCode == "k" then
if Debounce == false then
Debounce = true
print("Doing Pushups")
DoPushUpsEvent:FireServer()
wait(1.5)
Debounce = false
end
end
else if Debounce then return
end
end
end)
ServerScriptStorage:
-- Services
local PushUpsEvent = ReplicatedStorage:WaitForChild("PushUps")
-- Variables
local function PushUps(Player, KeyCode)
local StrengthValue = Player.Stats.Strength
local PlayerCharacter = game.Workspace:WaitForChild(Player.Name)
local PlayerHumanoid = Player.Character:WaitForChild("Humanoid")
local PushUpAnimationDefault = Instance.new("Animation")
PushUpAnimationDefault.AnimationId = "rbxassetid://10903310888"
local PushUpAnimationDefaultPlay = PlayerHumanoid:LoadAnimation(PushUpAnimationDefault, PlayerCharacter.Head)
local PushUpsAnimation = Instance.new("Animation")
PushUpsAnimation.AnimationId = "rbxassetid://10903098198"
local PushUpsAnimationPlay = PlayerHumanoid:LoadAnimation(PushUpsAnimation, PlayerCharacter.Head)
PlayerHumanoid.WalkSpeed = 0
PushUpAnimationDefaultPlay:Stop()
PushUpsAnimationPlay:Play()
StrengthValue.Value = StrengthValue.Value + 1
wait(1)
PushUpsAnimationPlay:Stop()
PlayerHumanoid.WalkSpeed = 16
if KeyCode == "j" then
return
end
end
PushUpsEvent.OnServerEvent:Connect(PushUps)`