Slide Script [HELP]

I have a sliding script and it will work for a few seconds and then just stop. Also it will stop working when you rotate your camera. I have literally no clue how to fix then so if you know the issue it’d be a huge help.

local humanoid = script.Parent:WaitForChild("Humanoid")

local anim = humanoid:LoadAnimation(script:WaitForChild("SlideAnimation"))


local uis = game:GetService("UserInputService")


uis.InputBegan:Connect(function(inp, processed)

	if processed then return end


	if inp.KeyCode == Enum.KeyCode.C then

		anim:Play()

		humanoid.HipHeight = 1.1
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 50

	end
end)


uis.InputEnded:Connect(function(inp)

	if inp.KeyCode == Enum.KeyCode.C then

		anim:Stop()
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16

		humanoid.HipHeight = 0

	end
end)
local UIS = game:GetService("UserInputService")
local char = script.Parent
local playerGui = game.Players.LocalPlayer.PlayerGui

local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://131538945837384"

local keybind = Enum.KeyCode.C
local canslide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if not canslide then return end

	if input.KeyCode == keybind then
		canslide = false

		local playAnim = char.Humanoid:LoadAnimation(slideAnim)
		playAnim:Play()

		local slide = Instance.new("BodyVelocity")
		slide.MaxForce = Vector3.new(1,0,1) * 30000
		slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 250
		slide.Parent = char.HumanoidRootPart

		for count = 1, 8 do
			wait(0.1)
			slide.Velocity*= 0.7
		end
		playAnim:Stop()
		slide:Destroy()
		wait(1.5)
		canslide = true
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.