Hey guys, Im working on a slap battles fanmade game and i added a ragdoll system and it works pretty well but im having issues with the dummy getting up.
It keeps flinging the dummy so i tried to change the rotation of the dummy’s humanoidRootPart and position it correctly and it works smoothly but when you double hit the dummy or hit the dummy right after he unragdolls, the client thinks hes standing but the server thinks hes 2 studs below the humanoidRootPart and it kinda just bugs the whole dummy out. And also, i use lookvector to determin the slap direction and the server sometimes think hes also tilted which messes up the slap direction.
Same thing happens to players.
The client:
The server:
The server when were tilted:
The white parts is his humanoidRootPart.
Any help?
Heres my code
local MS = game:GetService("MarketplaceService")
local x2 = 734843025
local x5 = 734537027
local x8 = 735706309
local Tool = script.Parent.Parent
local Debris = game:GetService("Debris")
local Anim = script:WaitForChild("SlapAnim")
local Power = script.Power
local CD = script.CD
local RagTime = script.RagTime
local AnimTrack
local LP = game:GetService("ServerStorage"):FindFirstChild("LimbPart")
local event = game:GetService("ReplicatedStorage"):WaitForChild("RagCameraChange")
local event2 = game:GetService("ReplicatedStorage"):WaitForChild("UnragCameraChange")
local event3 = game:GetService("ServerStorage"):WaitForChild("GiveSlapsEvent")
local hitChars = {}
local debounce = false
Tool.Activated:Connect(function()
if debounce then
return
end
debounce = true
local humanoid = Tool.Parent:FindFirstChild("Humanoid")
if not AnimTrack then
AnimTrack = humanoid:LoadAnimation(Anim)
end
AnimTrack:Play()
task.wait(CD.Value)
debounce = false
end)
Tool.Hitbox.Touched:Connect(function(hit)
if hitChars[hit.Parent] or not debounce then
return
end
if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("Invincible") then
local player = game.Players:GetPlayerFromCharacter(Tool.Parent)
local eChar = hit.Parent
local plrChar = Tool.Parent
local eHumanRootPart = eChar:FindFirstChild("HumanoidRootPart")
local plrHumanRootPart = plrChar:FindFirstChild("HumanoidRootPart")
local oldJump = eChar.Humanoid.JumpPower
local FXPart = Instance.new("Part", workspace)
FXPart.Size = Vector3.new(1,1,1)
FXPart.CanCollide = false
FXPart.CFrame = eHumanRootPart.CFrame
FXPart.Anchored = true
FXPart.Transparency = 1
local SlapCo = coroutine.create(function()
local f = script.Parent.Parent.HitEffectPart.HitEffect1:Clone()
local f2 = script.Parent.Parent.HitEffectPart.HitEffect2:Clone()
f.Enabled = true
f.Parent = FXPart
f2.Enabled = true
f2.Parent = FXPart
task.wait(0.2)
f.Enabled = false
task.wait(0.1)
f2:Destroy()
task.wait(0.825)
f:Destroy()
end)
local SoundCo = coroutine.create(function()
local s = script.Parent.Parent.Hand.Hardslapsound:Clone()
s:Play()
s.Parent = FXPart
s.PlaybackSpeed = 1
task.wait(1)
s:Destroy()
end)
local InvinCo = coroutine.create(function()
local invincible = Instance.new("BoolValue", hit.Parent)
invincible.Name = "Invincible"
task.wait(0.5)
invincible:Destroy()
end)
if plrHumanRootPart and eHumanRootPart then
if hit.Parent.Name ~= plrChar.Name then
coroutine.resume(SlapCo)
coroutine.resume(SoundCo)
coroutine.resume(InvinCo)
eChar.Humanoid.PlatformStand = true
eChar.Humanoid.JumpPower = 0
for index,joint in pairs(hit.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
a1.Name = "RagdollAttatchment"
local a2 = Instance.new("Attachment")
a2.Name = "RagdollAttatchment"
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
socket.Radius = 20
joint.Enabled = false
if not hit.Parent:FindFirstChild("Right Arm"):FindFirstChild("LimbPart") then
local RAclonedLP = LP:Clone()
RAclonedLP.Position = hit.Parent:FindFirstChild("Right Arm").Position
RAclonedLP.Orientation = hit.Parent:FindFirstChild("Right Arm").Orientation
local RAWeld = Instance.new("WeldConstraint", RAclonedLP)
RAWeld.Part0 = hit.Parent:FindFirstChild("Right Arm")
RAWeld.Part1 = RAclonedLP
RAclonedLP.Parent = hit.Parent:FindFirstChild("Right Arm")
end
if not hit.Parent:FindFirstChild("Left Arm"):FindFirstChild("LimbPart") then
local LAclonedLP = LP:Clone()
LAclonedLP.Position = hit.Parent:FindFirstChild("Left Arm").Position
LAclonedLP.Orientation = hit.Parent:FindFirstChild("Left Arm").Orientation
local LAWeld = Instance.new("WeldConstraint", LAclonedLP)
LAWeld.Part0 = hit.Parent:FindFirstChild("Left Arm")
LAWeld.Part1 = LAclonedLP
LAclonedLP.Parent = hit.Parent:FindFirstChild("Left Arm")
end
if not hit.Parent:FindFirstChild("Right Leg"):FindFirstChild("LimbPart") then
local RLclonedLP = LP:Clone()
RLclonedLP.Position = hit.Parent:FindFirstChild("Right Leg").Position
RLclonedLP.Orientation = hit.Parent:FindFirstChild("Right Leg").Orientation
local RLWeld = Instance.new("WeldConstraint", RLclonedLP)
RLWeld.Part0 = hit.Parent:FindFirstChild("Right Leg")
RLWeld.Part1 = RLclonedLP
RLclonedLP.Parent = hit.Parent:FindFirstChild("Right Leg")
end
if not hit.Parent:FindFirstChild("Left Leg"):FindFirstChild("LimbPart") then
local LLclonedLP = LP:Clone()
LLclonedLP.Position = hit.Parent:FindFirstChild("Left Leg").Position
LLclonedLP.Orientation = hit.Parent:FindFirstChild("Left Leg").Orientation
local LLWeld = Instance.new("WeldConstraint", LLclonedLP)
LLWeld.Part0 = hit.Parent:FindFirstChild("Left Leg")
LLWeld.Part1 = LLclonedLP
LLclonedLP.Parent = hit.Parent:FindFirstChild("Left Leg")
end
end
end
for i,v in ipairs(eChar:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = true
end
end
if game.Players:GetPlayerFromCharacter(eChar) then
event:FireClient(game.Players:GetPlayerFromCharacter(eChar))
eChar.CanActivateShiftlock.Value = false
eChar.IsRagdolled.Value = true
end
local force = Instance.new("BodyVelocity", eHumanRootPart)
force.MaxForce = Vector3.new(8, 8, 8) * math.huge
local direction = (plrChar.Head.CFrame.LookVector)
force.Velocity = (direction + Vector3.new(0,0.6,0)).Unit * Power.Value * 1.3
local rotation = Instance.new("BodyAngularVelocity", eHumanRootPart)
rotation.AngularVelocity = Vector3.new(1,1,1) * math.pi * 4
rotation.MaxTorque = Vector3.new(2,2,2) * math.huge
rotation.P = 5000
eChar.Humanoid:TakeDamage(Power.Value / 10)
task.wait(0.05)
for i,v in ipairs(eChar:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = false
end
end
Debris:AddItem(force,0.19)
Debris:AddItem(rotation,0.35)
event3:Fire(player)
Debris:AddItem(force,0.19)
Debris:AddItem(rotation,0.5)
end
task.wait(RagTime.Value - 0.05)
-- This part is the part im having issues with --
eChar.Humanoid.PlatformStand = false
eHumanRootPart.Orientation = Vector3.new(0,eHumanRootPart.Orientation.Y,0)
eHumanRootPart.Position += Vector3.new(0,2,0)
------------------------------------------------------------------
FXPart:Destroy()
for i, attatchment in pairs(hit.Parent:GetDescendants() )do
if attatchment.Name == "RagdollAttatchment" then
attatchment:Destroy()
end
end
for index,joint in pairs(hit.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
local RA = hit.Parent:FindFirstChild("Right Arm"):FindFirstChild("LimbPart")
local LA = hit.Parent:FindFirstChild("Left Arm"):FindFirstChild("LimbPart")
local RL = hit.Parent:FindFirstChild("Right Leg"):FindFirstChild("LimbPart")
local LL = hit.Parent:FindFirstChild("Left Leg"):FindFirstChild("LimbPart")
if RA then
hit.Parent:FindFirstChild("Right Arm"):FindFirstChild("LimbPart"):Destroy()
end
if LA then
hit.Parent:FindFirstChild("Right Leg"):FindFirstChild("LimbPart"):Destroy()
end
if RL then
hit.Parent:FindFirstChild("Left Arm"):FindFirstChild("LimbPart"):Destroy()
end
if LL then
hit.Parent:FindFirstChild("Left Leg"):FindFirstChild("LimbPart"):Destroy()
end
end
end
eChar.Humanoid.JumpPower = oldJump
if game.Players:GetPlayerFromCharacter(eChar) then
event2:FireClient(game.Players:GetPlayerFromCharacter(eChar))
eChar.CanActivateShiftlock.Value = true
eChar.IsRagdolled.Value = true
end
end
end
end)
im not the best at scripting lol. The rest of the code yall dont need to care about.
I’ve just set the cooldown longer so u cant double hit. Its temporarily fixed but it messus up combos and stuff