as you can see:
whenever i bump into a wall i completely lose control of the movement and it just pushes me in the same direction making me stuck,
when i only hold the key C, the game will start making me move around in a circle
if i also hit something my character will STRAIGHT UP get flung
code: (server)
local Folder = script.Parent
local RemoteEvent = Folder.RemoteEvent
local Players = game:GetService('Players')
local TweenService = game:GetService('TweenService')
local SlideThreads = {}
local SprintThreads = {}
local Instances = {}
RemoteEvent.OnServerEvent:Connect(function(player, command)
local Character = player.Character
local RootPart : BasePart = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if command == "SlideStart" then
Character:SetAttribute("Sliding", true)
SlideThreads[Character] = {}
Instances[Character] = {
Multiplier1 = nil,
Multiplier2 = nil,
Velocity = nil,
Animation = nil,
}
local MainThread = task.spawn(function()
Humanoid.CameraOffset = Vector3.new(0,-2,0)
local Multiplier = Instance.new("NumberValue")
local SlopeMultiplier = Instance.new("NumberValue")
local Speed = 70
local Velocity = Instance.new("BodyVelocity")
Velocity.MaxForce = Vector3.new(1, 0, 1)*17000
Velocity.Parent = RootPart
Velocity.Velocity = RootPart.CFrame.LookVector
Velocity.Name = "SlideVelocity"
local CD1=false
local CD2=false
local SlideAnimation = Humanoid:LoadAnimation(script.Slide)
SlideAnimation.Looped = true
SlideAnimation:Play()
Instances[Character].Animation = SlideAnimation
Instances[Character].Velocity = Velocity
Instances[Character].Multiplier1 = Multiplier
Instances[Character].Multiplier2 = SlopeMultiplier
SlopeMultiplier.Value = 1
Multiplier.Value = 1
local Rah = nil
local FollowThread = task.spawn(function()
local lastPosition = RootPart.Position
local lastWedge = nil
while task.wait() do
local Params = RaycastParams.new();
local Shapes = {Enum.PartType.Wedge}
local Filter = {Character}
Params.FilterDescendantsInstances = Filter
Params.FilterType = Enum.RaycastFilterType.Exclude
local Direction = Vector3.new(0, -(RootPart.Size.Y+3), 0)
local Raycast = workspace:Raycast(RootPart.Position, Direction, Params)
if Raycast and Raycast.Instance then
local inst : Part = Raycast.Instance
if inst.Shape == Enum.PartType.Wedge then
local isLower = ((RootPart.Position - lastPosition).Y < 0)
if not isLower and not CD1 then
if lastWedge and lastWedge ~= inst then
SlopeMultiplier.Value -= .5
elseif not lastWedge then
SlopeMultiplier.Value -= .5
lastWedge = inst
end
elseif isLower then
if lastWedge and lastWedge ~= inst then
SlopeMultiplier.Value += .7
elseif not lastWedge then
SlopeMultiplier.Value += .7
lastWedge = inst
end
if Rah then Rah:Cancel() end
Multiplier.Value = 1
Rah = TweenService:Create(
Multiplier,
TweenInfo.new(10, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{Value = 0}
)
Rah:Play()
end
lastWedge = inst
end
end
Velocity.Velocity = RootPart.CFrame.LookVector * (Speed*SlopeMultiplier.Value*Multiplier.Value)
lastPosition = RootPart.Position
end
end)
table.insert(SlideThreads[Character], FollowThread)
Rah = TweenService:Create(
Multiplier,
TweenInfo.new(10, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{Value = 0}
)
Rah:Play()
end)
table.insert(SlideThreads[Character], MainThread)
elseif command == "SlideStop" then
Humanoid.CameraOffset = Vector3.new(0,0,0)
Character:SetAttribute("Sliding", false)
Instances[Character].Velocity:Destroy()
Instances[Character].Multiplier1:Destroy()
Instances[Character].Multiplier2:Destroy()
Instances[Character].Animation:Stop()
for i,v in SlideThreads[Character] do
pcall(task.cancel, v)
end
SlideThreads[Character] = {}
end
end)