so i’ve been trying to make a double jump, right? part of a movement system that im making. everything in my scripts works, except for the humanoid:ChangeState(Enum.HumanoidStateType.Jumping). devforum hasnt told me anything, even though theres another topic with the exact same name.
theres also dash mechanics too, just ignore em’
LOCAL SCRIPT:
local userinputservice = game:GetService("UserInputService")
local dashCharges = script.Parent.Stats.Stamina
local hrp = script.Parent:FindFirstChild("HumanoidRootPart")::Part
local hum = script.Parent:FindFirstChildOfClass("Humanoid")
local RunService = game:GetService("RunService")
task.spawn(function()
while wait(2) do
if dashCharges.Value < 3 then
dashCharges.Value += 1
end
end
end)
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and dashCharges.Value > 0 then
dashCharges.Value -= 1
local moveVector = Vector3.new(0,0,0)
local keysHeld = userinputservice:GetKeysPressed()
for _,key in pairs(keysHeld) do
if key.KeyCode == Enum.KeyCode.W then
moveVector += hrp.CFrame.LookVector
end
if key.KeyCode == Enum.KeyCode.S then
moveVector -= hrp.CFrame.LookVector
end
if key.KeyCode == Enum.KeyCode.A then
moveVector -= hrp.CFrame.RightVector
end
if key.KeyCode == Enum.KeyCode.D then
moveVector += hrp.CFrame.RightVector
end
end
script.Parent:WaitForChild("Events"):FindFirstChild("Dash"):FireServer(moveVector)
end
if input.KeyCode == Enum.KeyCode.Space and dashCharges.Value > 0 then
if hum:GetState() == Enum.HumanoidStateType.Freefall or hum:GetState() == Enum.HumanoidStateType.Jumping then
dashCharges.Value -= 1
script.Parent:WaitForChild("Events"):FindFirstChild("DoubleJump"):FireServer()
end
end
end)
SERVER SCRIPT:
local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
local hrp = character:FindFirstChild("HumanoidRootPart")
local soundservice = game:GetService("SoundService")
local tweenservice = game:GetService("TweenService")
local dashEvent = character:WaitForChild("Events"):FindFirstChild("Dash")
local DoubleJumpEvent = character:WaitForChild("Events"):FindFirstChild("DoubleJump")
humanoid.WalkSpeed = 24
humanoid.JumpPower = 70
function stun(stunTime)
task.spawn(function()
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
wait(stunTime)
humanoid.WalkSpeed = 24
humanoid.JumpPower = 70
end)
end
dashEvent.OnServerEvent:Connect(function(player,moveVector)
stun(0.3)
local direction = moveVector
soundservice.Dash:Play()
local velocity = Instance.new("LinearVelocity")
velocity.Attachment0 = hrp:FindFirstChild("RootAttachment")
velocity.Attachment1 = hrp:FindFirstChild("RootAttachment")
velocity.VectorVelocity = direction*50
velocity.Parent = hrp
velocity.MaxForce = 10000
game.Debris:AddItem(velocity,0.3)
end)
DoubleJumpEvent.OnServerEvent:Connect(function()
print("dj")
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end)