I have came here because there is something wrong with my sliding script.
I’ve used references from:
There are no related errors being returned. This script was obtained through searching version history. Mind you that this script worked before.
uis = game:GetService("UserInputService")
local Tool = script.Parent
local plr = game:GetService("Players")
local char = plr.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local lastTime = tick()
anim = hum:LoadAnimation(game.ReplicatedStorage.Animations.PrimarySprint)
local RootPart = char:WaitForChild("HumanoidRootPart")
local RollTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations:WaitForChild("SlideAnimation"))
repeat wait() until RollTrack.Length ~= 0
local RollStartTime = 0
local RollDirection = Vector3.new()
local RollMult = 25/RollTrack.Length
local DB = false
local Sliding = false
local TweenService = game:GetService("TweenService")
wait(.75)
char.Humanoid.WalkSpeed = 15
hum.JumpPower = 37
-- Offset Function
function ChangeCameraOffset(Offset)
if not char then char = plr.Character or plr.CharacterAdded:Wait() end
local Humanoid = char:WaitForChild("Humanoid")
local Tween = TweenService:Create(Humanoid, TweenInfo.new(0.1), {CameraOffset = Offset})
Tween:Play()
end
-- Sprint
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and Sliding == false then
anim:Play()
char.Humanoid.WalkSpeed = 30
uis.MouseIconEnabled = false
end
end)
uis.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
char.Humanoid.WalkSpeed = 15
anim:Stop()
uis.MouseIconEnabled = false
end
end)
-- Slide Function
local LastBeat = tick()
game:GetService("RunService").Heartbeat:Connect(function()
local dT = tick()-LastBeat
LastBeat = tick()
if tick()-RollStartTime < .75 then
RootPart.CFrame = CFrame.new(RollDirection*dT*RollMult) * RootPart.CFrame
end
if Sliding == true then
ChangeCameraOffset(Vector3.new(0, -2, 0))
hum.JumpPower = 0
else
ChangeCameraOffset(Vector3.new(0, 0.475, 0))
hum.JumpPower = 37
end
end)
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.LeftShift and uis:IsKeyDown(Enum.KeyCode.C) and DB == false and tick()-RollStartTime > .75 and hum.MoveDirection.Magnitude > 0 then
anim:Stop()
Sliding = true
RollTrack:Play()
RollStartTime = tick()
local dirVec = workspace.CurrentCamera.CFrame.LookVector
RollDirection = (dirVec*Vector3.new(1,0,1)).unit
DB = true
RollTrack:Stop()
wait(1)
Sliding = false
wait(1)
DB = false
end
end)
What do you mean by that? Is it not playing? Is it not doing what you intended it to do? Like what exactly is the issue you want to be solve?
Regardless if something doesn’t display an error and still isn’t working, just drop a few prints under every if statement and/or loop. See what prints and what doesn’t to narrow down the issue.
Yes, The animation is not playing and the sprint is not either. The sprint by itself works, but when accompanied by the sliding script, it completely breaks. I have been adding prints, but for the sake of connivence, I’ve removed them for your viewing sake.
print("start")
uis = game:GetService("UserInputService")
local Tool = script.Parent
local plr = game:GetService("Players")
local char = plr.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local lastTime = tick()
anim = hum:LoadAnimation(game.ReplicatedStorage.Animations.PrimarySprint)
local RootPart = char:WaitForChild("HumanoidRootPart")
local RollTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations:WaitForChild("SlideAnimation"))
repeat wait() until RollTrack.Length ~= 0
local RollStartTime = 0
local RollDirection = Vector3.new()
local RollMult = 25/RollTrack.Length
local DB = false
local Sliding = false
local TweenService = game:GetService("TweenService")
print("variables")
wait(.75)
char.Humanoid.WalkSpeed = 15
hum.JumpPower = 37
print("character ajustments")
function ChangeCameraOffset(Offset)
if not char then char = plr.Character or plr.CharacterAdded:Wait() end
local Humanoid = char:WaitForChild("Humanoid")
local Tween = TweenService:Create(Humanoid, TweenInfo.new(0.1), {CameraOffset = Offset})
Tween:Play()
end
print("camera function")
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and Sliding == false then
anim:Play()
char.Humanoid.WalkSpeed = 30
uis.MouseIconEnabled = false
end
end)
uis.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
char.Humanoid.WalkSpeed = 15
anim:Stop()
uis.MouseIconEnabled = false
end
end)
print("sprint")
local LastBeat = tick()
game:GetService("RunService").Heartbeat:Connect(function()
local dT = tick()-LastBeat
LastBeat = tick()
if tick()-RollStartTime < .75 then
RootPart.CFrame = CFrame.new(RollDirection*dT*RollMult) * RootPart.CFrame
end
if Sliding == true then
ChangeCameraOffset(Vector3.new(0, -2, 0))
hum.JumpPower = 0
else
ChangeCameraOffset(Vector3.new(0, 0.475, 0))
hum.JumpPower = 37
end
end)
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.LeftShift and uis:IsKeyDown(Enum.KeyCode.C) and DB == false and tick()-RollStartTime > .75 and hum.MoveDirection.Magnitude > 0 then
anim:Stop()
Sliding = true
RollTrack:Play()
RollStartTime = tick()
local dirVec = workspace.CurrentCamera.CFrame.LookVector
RollDirection = (dirVec*Vector3.new(1,0,1)).unit
DB = true
RollTrack:Stop()
wait(1)
Sliding = false
wait(1)
DB = false
end
end)
print("end")
It seems some variables are not passing the prints
Yes, I’m currently looking into that. It prints end. But the sliding does not work. The animations, the camera, nothing works. Only sprint & animations.
Well remove the loop and repeat the process. Note you don’t have to put a print under every single line. Just put prints under anything that can yield (loops, waitForChild(), etc) and all conditional statements (if statements, etc). You can remove the old prints so they don’t clutter the output.
Try to put a few prints inside your InputBegan and inputEnded connections. One right after you make the connection (so you know its running) and one right after the if statement (to see if the condition is met)