#sliding into objects causes flinging

1 messages · Page 1 of 1 (latest)

celest scarab
#

please help me

#

local UIS = game:GetService("UserInputService")
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local slideAnim = Instance.new("Animation")
local ca = tostring(script:WaitForChild("SlideAnim").AnimationId)
slideAnim.AnimationId = ca
local keybind = Enum.KeyCode.LeftShift
local canslide = true
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if not canslide then return end
-- 🔒 BLOCCO SLIDE DA FERMO
-- Puoi cambiare soglia se vuoi (4 = minimo movimento)
local moving = humanoid.MoveDirection.Magnitude > 0.1
if not moving then return end
if input.KeyCode == keybind then
canslide = false
local playAnim = humanoid:LoadAnimation(slideAnim)
playAnim:Play()
playAnim:AdjustSpeed(0.5)
local snd = script.Slide
snd:Play()
local slide = Instance.new("BodyVelocity")
slide.MaxForce = Vector3.new(1, 0, 1) * 300000
slide.Parent = char.HumanoidRootPart
local currentSpeed = 50
local maxSpeed = 60
local acceleration = 10
local steps = 10
for i = 1, steps do
slide.Velocity = char.HumanoidRootPart.CFrame.LookVector * currentSpeed
currentSpeed = math.min(currentSpeed + acceleration, maxSpeed)
task.wait(0.1)
end
task.wait(0.3)
slide.Velocity = Vector3.new(0, 0, 0)
playAnim:Stop()
slide:Destroy()
task.wait(2)
canslide = true
end
end)

indigo oxide
#

As like the sliding animation should ignore the objects and continue the slide smooth.

stray ingot
# celest scarab local UIS = game:GetService("UserInputService") local char = script.Parent local...

a bit hard to read without the markdown. But i had a problem like this before, it was because i was applying too much force into the player's character and it'll end up flinging away when hitting an anchored part (I'm never using math.huge for stuff like that ever again 😭). Maybe try reducing the MaxForce property, that could help. Also, BodyVelocity is deprecated, try using LinearVelocity instead