When the player gets up after I ragdoll them sometimes they fling around and it kinda ruins the game
Here’s my script
HitEvt.OnServerEvent:Connect(function(player, hithum, ToolModule, tool, Uses)
local Module = require(ToolModule)
if not hithum then return end
hithum:TakeDamage(Module.Damage)
-----------------------------
if Module.Stun then
local character = hithum.Parent
if character and character:IsA("Model") then
local humanoid = character:FindFirstChildOfClass("Humanoid")
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoid then
humanoid:UnequipTools()
humanoid.PlatformStand = true
humanoid.AutoRotate = false
end
for _, joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") and joint.Part0 and joint.Part1 then
joint.Enabled = false
local attach0 = Instance.new("Attachment", joint.Part0)
local attach1 = Instance.new("Attachment", joint.Part1)
attach0.CFrame = joint.C0
attach1.CFrame = joint.C1
local socket = Instance.new("BallSocketConstraint")
socket.Attachment0 = attach0
socket.Attachment1 = attach1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
socket.Parent = joint.Parent
local ghostPart = Instance.new("Part")
ghostPart.Size = Vector3.new(0.95, 0.95, 0.95)
ghostPart.Transparency = 1
ghostPart.CanCollide = true
ghostPart.CanQuery = false
ghostPart.CanTouch = false
ghostPart.Anchored = false
ghostPart.Name = "GhostLimbPart"
ghostPart.Parent = character
ghostPart.CFrame = joint.Part1.CFrame
ghostPart.CollisionGroup="UncollidableProps"
local weld = Instance.new("WeldConstraint")
weld.Part0 = joint.Part1
weld.Part1 = ghostPart
weld.Parent = ghostPart
end
end
local targetPlayer = Players:GetPlayerFromCharacter(character)
if targetPlayer then
RagdollEvt:FireClient(targetPlayer, Module.StunTme)
end
task.delay(Module.StunTme, function()
for _, obj in pairs(character:GetDescendants()) do
if obj:IsA("Motor6D") then
obj.Enabled = true
elseif obj:IsA("BallSocketConstraint") or obj:IsA("Attachment") or obj.Name == "GhostLimbPart" then
obj:Destroy()
end
end
if humanoid then
humanoid.PlatformStand = false
humanoid.AutoRotate = true
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)
end
end
end)
What did I do wrong?
I did call
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)