I’ve been attempting to create a sliding function that ends when the key is let go, or when the speed hits 0.
I’m very new to this sorry if you see any obvious problems lol,
Issue #1: I have no idea how to tween a number, but I assume I did it correctly
Issue #2: I want to return the Slide tween so I can delete the BodyVelocity when it finishes.
Issue #3: I want to activate a “issliding” value when the slide finishes and when it starts for later usage. This is supposed to be a technical Fast-Paced movement based combat system.
SLIDE FUNCTION
local function slide(slidespeed)
local SlideValue = Instance.new("NumberValue")
SlideValue.Value = slidespeed
local speed = SlideValue.Value
Humanoid.WalkSpeed = 0
local Slide = TweenService:Create(speed, TweenInfo.new(speed/4), {Value = 0})
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
Slide:Play()
BV.Velocity = HumanoidRP.CFrame.LookVector * speed
Slide.Completed:Connect(function()
BV:Destroy()
Humanoid.WalkSpeed = 16
end)
return BV
end
CAS FUNCTION
local function activateslide(name, state, type)
if state == Enum.UserInputState.Begin and isrunning then
slide(Humanoid.WalkSpeed * 1.5)
issliding = true
end
if state == Enum.UserInputState.End and issliding then
--end the tween here, which in turn destroys the bodyvelocity
end
end
(put it in dummy terms)