Hi, so I am creating a ragdoll system mechanic using BallSocketConstraints, the disabling/enabling of Motor6Ds, AND using humanoid:ChangeState(Enum.HumanoidStateType.Physics) to simulate the ragdoll. However, I have used a ModuleScript (called from a LocalScript) to organize the functions more easily. For some reason, when the ragdoll plays, it is only seen by the player and not other players. I know it’s being called from a LocalScript, but it didn’t seem to work. There are no prints in the RemoteEvent or errors either. Here are my scripts (labelled):
ModuleScript:
local FallMechanic = {}
local RagdollEvent = script.RagdollEvent
function FallMechanic.FallDamage(player, character, humanoid)
local LeftLeg = character:WaitForChild("Left Leg")
local VelocityNumber = LeftLeg.Velocity.Y
VelocityNumber = math.abs(VelocityNumber)
VelocityNumber = math.floor(VelocityNumber)
print(VelocityNumber)
if VelocityNumber > 80 then
local DamageTaken = VelocityNumber / 5
DamageTaken = math.floor(DamageTaken)
if VelocityNumber > 120 then
DamageTaken = VelocityNumber / 4
DamageTaken = math.floor(DamageTaken)
end
if DamageTaken > 15 then
local WaitingTime = DamageTaken * 0.1
if humanoid.Health > 5 then
humanoid.Health = math.clamp(humanoid.Health - DamageTaken, 5, 100)
if humanoid.Health ~= 5 then
RagdollEvent:FireServer(character, humanoid, false)
wait(WaitingTime)
RagdollEvent:FireServer(character, humanoid, true)
end
end
elseif DamageTaken < 15 and DamageTaken > 13 then
humanoid.Health = math.clamp(humanoid.Health - DamageTaken, 5, 100)
end
end
end
LocalScript that is calling the ModuleScript:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)
local FallMechanic = require(game.ReplicatedStorage.FallMechanic)
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Landed then
FallMechanic.FallDamage(player, character, humanoid)
end
end)
RemoteEvent I have been using to make the ragdoll able to be seen by other players:
local RemoteEvent = game.ReplicatedStorage.FallMechanic.RagdollEvent
RemoteEvent.OnServerEvent:Connect(function(character, humanoid, getUp)
if getUp == false then
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = false
end
end
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
elseif getUp == true then
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true
end
end
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)