Custom Character wont jump and plays walk animation

So basically i have made a custom character and animations and when i jump it barely jumps and plays the walk animation, i havent set a jump animation,I have tried but it also dosent work, also i have made an animate localScript to replace the default one here’s a video, i dont think the script is a problem but i also will attatch the script. This my first official project i am frustated

2024-06-29 17-08-45.zip (6.7 MB)

local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")

local player = game:GetService("Players").LocalPlayer
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local animationId = "18224411925"
local dashAnimationId = "1718490667"
local cameraOffsetOn = Vector3.new(0, 0, 0)
local cameraOffsetOff = Vector3.new(0, 0, 0)
local dashSound = workspace.dash8

local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)


local crouchedWalkSpeed = 12
local standindWalkSpeed = 20
local playBackSpeedCrouching = .7
local playBackSpeedStanding = 2

local sprintingWalkSpeed = 15

local dashSpeed = 750
local dashDebounce = false
local dashCooldown = 0.5
local duration = .3

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. animationId
local crouchAnimation =  humanoid:LoadAnimation(animation)

local dashAnimation = script.Animation

local function setCrouchState(IsCrouching)
	if IsCrouching then
		humanoid.WalkSpeed -= crouchedWalkSpeed
		tweenService:Create(humanoid, TweenInfo.new(.25), { CameraOffset = cameraOffsetOn} ):Play()
		character.HumanoidRootPart.Running.PlaybackSpeed = playBackSpeedCrouching
		character.HumanoidRootPart.CanCollide = false
		walkAnimTrack:Stop()
		crouchAnimation:Play()
		
		while wait() do
			if humanoid.MoveDirection.Magnitude > 0 then
				crouchAnimation:AdjustSpeed(1)
			else
				crouchAnimation:AdjustSpeed(0)
			end
		end
	else
		humanoid.WalkSpeed = standindWalkSpeed
		tweenService:Create(humanoid, TweenInfo.new(0.25), { CameraOffset = cameraOffsetOff}):Play()
		character.HumanoidRootPart.Running.PlaybackSpeed = playBackSpeedStanding
		character.HumanoidRootPart.CanCollide = true
		crouchAnimation:Stop()
	end
end

userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent then
		if input.KeyCode == Enum.KeyCode.C or input.KeyCode == Enum.KeyCode.LeftControl or input.KeyCode == Enum.KeyCode.RightControl or input.KeyCode == Enum.KeyCode.ButtonB then
			setCrouchState(true)
		end
	end
end)

userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent then
		if input.KeyCode == Enum.KeyCode.C or input.KeyCode == Enum.KeyCode.LeftControl or input.KeyCode == Enum.KeyCode.RightControl or input.KeyCode == Enum.KeyCode.ButtonB then
			idleAnimTrack:Play()
			setCrouchState(false)
		end
	end
end)

local function setSprintState(IsSprinting)
	if IsSprinting then
		humanoid.WalkSpeed += sprintingWalkSpeed
		tweenService:Create(humanoid, TweenInfo.new(.25), { CameraOffset = cameraOffsetOn} ):Play()
		character.HumanoidRootPart.CanCollide = false


	else
		humanoid.WalkSpeed = standindWalkSpeed
		tweenService:Create(humanoid, TweenInfo.new(0.25), { CameraOffset = cameraOffsetOff}):Play()
		character.HumanoidRootPart.Running.PlaybackSpeed = playBackSpeedStanding
		character.HumanoidRootPart.CanCollide = true
	end
end

userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent then
		if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift or input.KeyCode == Enum.KeyCode.ButtonY then
			setSprintState(true)
		end
	end
end)

userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent then
		if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift or input.KeyCode == Enum.KeyCode.ButtonY then
			setSprintState(false)
		end
	end
end)

local function Dash()
	if not dashDebounce then
		dashDebounce = true
		
		local humanoidRootPart = character.HumanoidRootPart
		local loadedAnimation = humanoid:LoadAnimation(dashAnimation)
		local dashDirection = nil
		local moveDirection = humanoid.MoveDirection
		local lookVector = humanoidRootPart.CFrame.lookVector
		local minusVelocity = -dashSpeed
		local isOnGround = humanoid.FloorMaterial ~= Enum.Material.Air 
		
		if isOnGround then
			
			if moveDirection == Vector3.new(0,0,0) then
				dashDirection = humanoidRootPart.Position + Vector3.new(lookVector.X, 0, lookVector.Z)
			else
				dashDirection = humanoidRootPart.Position + Vector3.new(moveDirection.X, 0, moveDirection.Z)
			end
			
			local alignOrientation = Instance.new("AlignOrientation")
			alignOrientation.Parent = humanoidRootPart
			alignOrientation.MaxTorque = math.huge
			alignOrientation.Responsiveness = 0
			alignOrientation.RigidityEnabled = 500000
			alignOrientation.CFrame = CFrame.lookAt(humanoidRootPart.Position, dashDirection )
			
			local attachment = Instance.new("Attachment")
			attachment.Parent = humanoidRootPart
			
			local vectorForce = Instance.new("VectorForce")
			vectorForce.Parent = humanoidRootPart
			vectorForce.Attachment0 = attachment
			
			vectorForce.Force = Vector3.new(0,0,minusVelocity)
			

			loadedAnimation:Play()
			dashSound:Play()
			humanoid.AutoRotate = false
			
			wait(duration)
			
			humanoid.AutoRotate = true
			
			vectorForce:Destroy()
			alignOrientation:Destroy()
			attachment:Destroy()
			
			wait(duration)
			loadedAnimation:Stop()
			
		end
		wait(dashCooldown)
		dashDebounce = false
	end
end

userInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q or input.KeyCode == Enum.KeyCode.ButtonX then
		Dash()
	end
end)

-- Anim Handler

-- Remeber to select the animtion object and set the id to your own!


humanoid.Running:Connect(function(speed)
	if speed > 0 then
		if not walkAnimTrack.IsPlaying and idleAnimTrack.IsPlaying then
			idleAnimTrack:Stop()
			walkAnimTrack:Play()
		end
	else
		if walkAnimTrack.IsPlaying and not idleAnimTrack.IsPlaying then
			idleAnimTrack:Play()
			walkAnimTrack:Stop()
		end
	end
end)

idleAnimTrack:Play()
3 Likes