Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to prevent character from falling/ ragdolling?

Asked by
fcvrs 22
2 years ago

I have a script that slides the character using BodyVelocity in my game. Whenever I slide into an object, the character will fall and bounce away and I'm trying to fix this.

Ive tried disabling humanoid states with this:

hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false) hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false) hum:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)

which hasnt helped, any other solutions?

3 answers

Log in to vote
0
Answered by 2 years ago

BodyVelocity Is Deprecated, meaning It will no longer work on new work, Instead, simply use VectorForce which more Information can be found here: https://developer.roblox.com/en-us/api-reference/class/VectorForce?adlt=strict&toWww=1&redig=F2CD645E683C41FA8C268A6FA7F4F231

(Note: The Information there might be outdated though)

0
Yeah, still doesnt help my problem fcvrs 22 — 2y
0
Correction: Deprecated still works. It doesn’t mean it’s wil no longer work. T3_MasterGamer 2189 — 2y
0
Alright imnotaguest1121 362 — 2y
0
but if it breaks it wont get fixed Puppynniko 1059 — 2y
Ad
Log in to vote
0
Answered by
Dexiber 272 Moderation Voter
2 years ago
Edited 2 years ago

You could just detect the state that changed, and see if its any of the ones you down want, then, set the state to freefall

Humanoid.StateChanged:Connect(function(old,new)
    if new == Enum.HumanoidStateType.Ragdolling or new == 
        Enum.HumanoidStateType.FallingDown 
    if new == Enum.HumanoidStateType.Ragdolling or new == 
        Enum.HumanoidStateType.Climbing then
        Humanoid:ChangeState(Enum.HumanoidStateType.FreeFall)
    end
end)
0
should cancel them out Dexiber 272 — 2y
0
ive already tried this and it didnt work fcvrs 22 — 2y
Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago

Alright no more problems, i'm here to help you!

Let's use RunService in order to make it run every frame!

It's also a ServerScript

local PlayersService = game:GetService("Players")
local RunService = game:GetService("RunService")

PlayersService.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        RunService.Heartbeat:Connect(function()

            char:FindFirstChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
            char:FindFirstChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
            char:FindFirstChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Climbing, false)

        end)
    end)
end)

Answer this question