Hi! So I have this problem with a knockback system I’m making. The knockback and rag doll works fine on dummies but not on players. Instead the player will just stand up while ragdolling.
I heard that it’s because Velocity is deprecated or something.
I don’t know the replacement or the new way of making knockback because I couldn’t find any info.
My script is a server script.
Script:
local touched = false
local TS = game:GetService("TweenService")
game.ReplicatedStorage.Throw.OnServerEvent:Connect(function(plr, mouseHit)
local clone = plr.Character:FindFirstChildWhichIsA("Tool").Handle:Clone()
plr.Character.Humanoid:LoadAnimation(script.Parent.Handle:FindFirstChild("Yeet")):Play()
clone.Hitbox.Touched:Connect(function(hit)
print(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= plr.Character and hit.Parent.Name ~= "Rope" then
if hit.Parent.Humanoid.Health > 0 then
if not touched then
local target = hit.Parent
local joints = target:GetDescendants()
target.Humanoid.BreakJointsOnDeath = false
touched = true
clone.CanTouch = false
target.HumanoidRootPart.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 160 + Vector3.new(0,160,0)
clone.Impact:Play()
print(hit.Parent.Name,"was hit by",script.Parent.Name)
hit.Parent:FindFirstChild("Humanoid").Health -= 10
for _,joint in pairs(joints) do
if joint:isA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")
print(joint)
target.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
target.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
target.Humanoid.AutoRotate = false
--target.Humanoid.PlatformStand = true
--target.Humanoid.WalkSpeed = 0
--target.Humanoid.JumpPower = 0
att0.Name = "Att0"
att1.Name = "Att1"
att0.CFrame = joint.C0
att1.CFrame = joint.C1
att0.Parent = joint.Part0
att1.Parent = joint.Part1
touched = true
clone.CanTouch = false
socket.Parent = joint.Part0
socket.Attachment0 = att0
socket.Attachment1 = att1
att0.Name = "Att0"
att1.Name = "Att1"
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
--wait(0.2)
--wait(2)
joint.Enabled = false
end
end
print(target)
print(target.Humanoid.Health)
wait(0.2)
clone:Destroy()
touched = false
clone.CanTouch = true
wait(1)
if hit.Parent.Humanoid.Health > 0 then
if target.Name ~= "Dummy3" then
target.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
target.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
target.Humanoid.AutoRotate = true
target.Humanoid.WalkSpeed = 26
target.Humanoid.JumpPower = 7.5
for _,joint2nd in pairs(joints) do
if joint2nd:isA("Motor6D") then
joint2nd.Enabled = true
end
for _, child in pairs(target:GetDescendants()) do
if child.Name == "Att0" or child.Name == "Att1" or child:IsA("BallSocketConstraint") then
child:Destroy()
end
end
end
end
end
end
end
end
end)
wait(0.4)
plr.Character:FindFirstChildWhichIsA("Tool").Handle.Woosh:Play()
wait(0.1)
plr.Character:FindFirstChildWhichIsA("Tool").Handle.Transparency = 1
clone.Transparency = 0
local tool = clone.Parent
clone.Parent = game.Workspace
clone.Anchored = true
clone.CanCollide = false
clone.Hitbox.CanCollide = false
clone.CanTouch = true
clone.Hitbox.CanTouch = true
print(clone.Parent)
-- clone.Position = script.Parent.Handle.Position
clone.CFrame = plr.Character.HumanoidRootPart.CFrame+plr.Character.HumanoidRootPart.CFrame.LookVector * 5
local Tween = TS:Create(clone,TweenInfo.new(0.5),{CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.LookVector * 80})
Tween:Play()
--print(mouseHit)
wait(0.45)
plr.Character:FindFirstChildWhichIsA("Tool").Handle.Transparency = 0
clone:Destroy()
end)
--clone.Touched:Connect(function(hit)
--local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
--print(plr,"was hit by",script.Parent.Name)
--end)