right now i’m working on making a ragdoll on hit script, in a 1/4 chance.
it works for the majority of the features i was hoping for! just a few bugs… and by a few i mean a lot.
i wanted to make a ragdoll on hit so i followed a tutorial and did some studies into it,
and ended up wtih a script looking like this:
Script
local tool = script.Parent.Parent
local canDamage = false
local debounce = false
local timer = true
local HitBox = script.Parent
local function onTouch(HitBox)
local humanoid = HitBox.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= HitBox.Parent.Parent and canDamage and debounce then
humanoid.BreakJointsOnDeath = false
wait(0.10)
if debounce then
local chance = math.random(1,4)
local character = humanoid.Parent
if chance == 1 and debounce then
humanoid.RequiresNeck = false
for index,joint in pairs(character:GetDescendants()) do
if joint:IsA('Motor6D') then
local socket = Instance.new('BallSocketConstraint')
local a1 = Instance.new('Attachment')
local a2 = Instance.new('Attachment')
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
character:BreakJoints()
wait(3)
character:MakeJoints()
debounce = false
end
end
end
else
print("UnLucky!")
debounce = false
return
end
end
canDamage = false
end
local function slash()
wait(0.5)
if timer == true then
local str = Instance.new("StringValue")
str.Value = "Slash"
str.Parent = tool
canDamage = true
debounce = true
timer = false
if timer == false then
wait(0.3)
timer = true
end
end
end
tool.Activated:Connect(slash)
tool.HitBox.Touched:Connect(onTouch)
although this is what happens:
https://i.gyazo.com/9bb3f1c34ac6468685aadf943beaea8f.mp4
and i want the player to not die, simply ragdoll and then recover after 3 seconds.
any help?
thanks for reading