if HumanoidHealth <= 20 then
player.CharacterAdded:Connect(function(char)
char:WaitForChild(“Humanoid”).BreakJointsOnDeath = false
char.Humanoid.Died:Connect(function()
for _, v in pairs(char:GetDescendants()) do
if v:IsA(“Motor6D”) then
local a0, a1 = Instance.new(“Attachment”), Instance.new(“Attachment”)
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new(“BallSocketConstraint”)
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v:Destroy()
end
end
char.HumanoidRootPart.CanCollide = false
end)
end)
end
end)
So basically what I’m tryna do is make a script where if a player health is 20 or less than it’ll ragdoll but I keep getting an error everytime and I’m struggling trying too figure out how too define a Humanoid Health here is the script
remove the variable for humanoid.health
Fixed script.
if Humanoid.Health <= 20 then
player.CharacterAdded:Connect(function(char)
char:WaitForChild(“Humanoid”).BreakJointsOnDeath = false
char.Humanoid.Died:Connect(function()
for _, v in pairs(char:GetDescendants()) do
if v:IsA(“Motor6D”) then
local a0, a1 = Instance.new(“Attachment”), Instance.new(“Attachment”)
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new(“BallSocketConstraint”)
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v:Destroy()
end
end
char.HumanoidRootPart.CanCollide = false
end)
end)
end
end)
im assuming you already have the humanoid variable
I didn’t ask for my scripted to get fixed I asked How do I define a humanoid Health on ServerSide
bruh… i defined it in my script but ok
Humanoid.Health
he’s calling it from a serverscript so lol
You edited your post for it to be on the server side. Personally, I would just use a RemoteEvent
for this.
yeah, remote events are the easiest way to do so
ah ok
30charactersrequirement!
Or, an alternative to remote events would just be to wrap the code in a PlayerAdded connection
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:WaitForChild(“Humanoid”).BreakJointsOnDeath = false
char.Humanoid.Died:Connect(function()
if char.Humanoid.Health <= 20 then
for _, v in pairs(char:GetDescendants()) do
if v:IsA(“Motor6D”) then
local a0, a1 = Instance.new(“Attachment”), Instance.new(“Attachment”)
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new(“BallSocketConstraint”)
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v:Destroy()
end
end
char.HumanoidRootPart.CanCollide = false
end
end)
end)
end)
I’m writing this on phone so someone correct any mistakes
is this the character way too define a humanoid local Humanoid = game.Players.Character.Humanoid?
local h = ragdoll.Humanoid
if h ~= nil then
health = h.Health
end
I’m still getting an error saying 19:48:51.952 - Character is not a valid member of Player
How can I use a RemoteEvent for it?
You should be waiting for the character to load on the server with
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()