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

1Humanoid.StateChanged:Connect(function(old,new)
2    if new == Enum.HumanoidStateType.Ragdolling or new ==
3        Enum.HumanoidStateType.FallingDown
4    if new == Enum.HumanoidStateType.Ragdolling or new ==
5        Enum.HumanoidStateType.Climbing then
6        Humanoid:ChangeState(Enum.HumanoidStateType.FreeFall)
7    end
8end)
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

01local PlayersService = game:GetService("Players")
02local RunService = game:GetService("RunService")
03 
04PlayersService.PlayerAdded:Connect(function(player)
05    player.CharacterAdded:Connect(function(char)
06        RunService.Heartbeat:Connect(function()
07 
08            char:FindFirstChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
09            char:FindFirstChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
10            char:FindFirstChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
11 
12        end)
13    end)
14end)

Answer this question