You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’m currently making a system with running, dashing and double jumping. -
What is the issue? Include screenshots / videos if possible!
For some reason, there are no errors in the output, but it doesn’t take away any stamina when I slide. (I haven’t added the stamina part to the other movements yet.) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried the devforum.
My slide script.
local UIS = game:GetService("UserInputService")
local char = script.Parent
local humanoid = char:FindFirstChildOfClass("Humanoid")
local rootPart = char:FindFirstChild("HumanoidRootPart")
local canslide = true
local keybind = Enum.KeyCode.V -- Key to activate slide
local Stamina = game.Players.LocalPlayer:GetAttribute("Stamina")
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://77407259532005" -- Enter your Animation ID
-- Function to check if the player is moving downhill
local function isGoingDownhill()
local rayOrigin = rootPart.Position
local rayDirection = Vector3.new(0, -5, 0) -- Cast downward
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {char}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local result = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if result then
local normal = result.Normal
local slopeAngle = math.deg(math.acos(normal:Dot(Vector3.new(0, 1, 0))))
return slopeAngle > 10 -- Returns true if the slope is steep enough
end
return false
end
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed or not canslide then return end
if input.KeyCode == keybind then
canslide = false
local playAnim = humanoid:LoadAnimation(slideAnim)
playAnim:Play()
local slide = Instance.new("BodyVelocity")
slide.MaxForce = Vector3.new(1, 0, 1) * 30000
slide.Velocity = rootPart.CFrame.lookVector * 85
slide.Parent = rootPart
-- Minimum slide time for flat surfaces
local slideTime = 0.8
local elapsedTime = 0
while elapsedTime < slideTime or isGoingDownhill() do
wait(0.1)
slide.Velocity *= 0.985 -- Reduced friction for longer sliding
elapsedTime += 0.1
end
playAnim:Stop()
slide:Destroy()
canslide = true
Stamina -= 10
end
end)