#Sprint button works weirdly

1 messages · Page 1 of 1 (latest)

ebon crane
#

Title says it all. I had coded in a sprint button which doesn't work as intended, and am now left a little confused as to why. When the player first presses shift they'll still be in sprinting mode even when they stop, and this only changes to the intended behavior (of holding it down at the same time) when the shift key is pressed a second time. Naturally, this is very annoying and I can see this error becoming a nuisance very quickly. . .

#

Sorry in advance for the .txt, discord won't let me post the full script otherwise ToT

plain veldt
#

typically not good

#

anyway

celest trellisBOT
#

studio** You are now Level 9! **studio

plain veldt
#

I see the reason

#

why

#

yeah ngl

#

u should prob rework

#

that

ebon crane
plain veldt
#

and honestly that alone would probably fix your problem

ebon crane
#

Ill try that out later this evening (I have chores to do lol)

#

But the original reason I put them into getpropertychangedsignal was so that my skating animation would actually stop and play respectively whenever the player character moves

#

Would it be easy to achieve the same effect without stuffing the inputs in there like I have now?

#

It probably is and im just not able to see it now xD

plain veldt
ebon crane
#

Ohhh okay, I see

ebon crane
#

By chance would you know how to get the animation to stop while the player is idle?

#
local function startSkating()
    skating = true
    humanoid.WalkSpeed = skateSpeed
    humanoid.JumpPower = 0
    skatingAnimTrack:Play()
end

local function stopSkating()
    skating = false
    skatingAnimTrack:Stop()
    humanoid.JumpPower = 30
    humanoid.WalkSpeed = normalWalkSpeed
end

--Skating keybinds
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
    if humanoid.MoveDirection.Magnitude > 0 and skatingAnimTrack.IsPlaying == false and skating == false then
        UserService.InputBegan:Connect(function(input, gameProcessedEvent)
            if Skate(input) then
                startSkating()
            end
        end)
    elseif humanoid.MoveDirection.Magnitude == 0 and skatingAnimTrack.IsPlaying == true and skating == true then
        stopSkating()
    end
end) --PC/Console```
#

Heres the current code related to it