Well, the title is self explanatory, I’ve made a slide script for my parkour game and It worked quite fine, didn’t give any error, but yesterday, the script started giving problems. I don’t really know why, I didn’t change anything on the script (I think) so I couldn’t realize why It started outputing infinite yields possible.
I’ve made some tweaks to the code that should break the infinite yield, but it’s still not working. Im 99% sure that the script is giving the problems, because I tried disabling all the scripts but I still can’t find the solution.
LocalScript's code
wait(1)
----------------
-- Services
----------------
local UserInput = game:GetService("UserInputService")
local ContextAction = game:GetService("ContextActionService")
----------------
-- Character
----------------
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded():Wait() or script.Parent.Parent
local hum = char:WaitForChild("Humanoid") or char.Humanoid
local hrp = char:WaitForChild("HumanoidRootPart") or char.HumanoidRootPart
print(char.Name)
print(hum.Name)
print(hrp.Name)
local doubleJumpDisabler = char:WaitForChild("Movement"):WaitForChild("doubleJump")
--// animations
local slide = game.ReplicatedStorage.slide:Clone()
slide.Parent = char
local slideAnim = hum:LoadAnimation(slide)
----------------
-- Values
----------------
local debounce = false
local oldPower
local oldAngle
-- Functions
local function slideRequest()
if (not debounce and hrp.Velocity.Magnitude > .5) then
if (hrp) then
hrp.CustomPhysicalProperties = PhysicalProperties.new(.7, 0.2, 0, 1, 0) --// Preventing nearly infinite sliding
end
debounce = true
oldPower = hum.JumpPower
oldAngle = hum.MaxSlopeAngle
hum.JumpPower = 0
hum.MaxSlopeAngle = 15
slideAnim:Play()
doubleJumpDisabler.Disabled = true
end
end
local function stopSlide(trigger)
if (hrp) then
hrp.CustomPhysicalProperties = PhysicalProperties.new(1.1, 0.2, 0, 1, 0) --// Setting back physical properties
end
slideAnim:Stop()
hum.JumpPower = oldPower
hum.MaxSlopeAngle = oldAngle
debounce = false
doubleJumpDisabler.Disabled = false
print(trigger)
end
local function update(dt)
if (debounce and hrp and hrp.Velocity.Magnitude <= .5) then
stopSlide(player.Name.." stopped sliding by "..hrp.Velocity.Magnitude)
end
end
local function stopSlideCheck()
if (debounce and hrp) then
stopSlide(player.Name.." stopped sliding")
end
end
----------------
-- Inputs
----------------
UserInput.InputBegan:Connect(function(input, gameProcessed)
if (input.UserInputType == Enum.UserInputType.Keyboard and hrp) then
if (input.KeyCode == Enum.KeyCode.LeftControl and not gameProcessed or input.KeyCode == Enum.KeyCode.C and not gameProcessed) then
slideRequest();
end
end
end)
UserInput.InputEnded:Connect(function(input, gameProcessed)
if (input.UserInputType == Enum.UserInputType.Keyboard and hrp) then
if (input.KeyCode == Enum.KeyCode.LeftControl and not gameProcessed or input.KeyCode == Enum.KeyCode.C and not gameProcessed) then
stopSlideCheck();
end
end
end)
game:GetService("RunService").RenderStepped:Connect(update)
The LocalScript is located into a folder at StarterCharacterScripts.
I’ve added some checks for the script and it seems to print everything correctly. You can see that it actually finds the HumanoidRootPart.