I want to create a knockback system. For some reason, whenever I knock a player back, the knockback is not displayed on the attacker’s side, but only the resulting position. The knockback is perfect for the player being knocked back.
This is a video of what I’m talking about:
https://streamable.com/mwjtvc
I’m using FireAllClients (as shown by the red highlight), so I really don’t understand what the problem is.
This is the server code:
v.Parent:FindFirstChild("Humanoid").PlatformStand = true
fm1de:FireAllClients(player, v)
v.Parent:WaitForChild("HumanoidRootPart").Orientation = player.Character.HumanoidRootPart.Orientation - Vector3.new(0,180,0)
hit:Play()
v.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
v.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
-- for index, joint in pairs(v.Parent:GetDescendants()) do
-- task.spawn(function() -- I put the SPAWN function here instead
-- 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
-- joint.Enabled = false
-- task.wait(1)
v.Parent:FindFirstChild("Humanoid").PlatformStand = false
v.Parent:FindFirstChild("Humanoid").WalkSpeed = 10
And the local code:
fm1de.OnClientEvent:Connect(function(player, v)
local mark = Instance.new("Highlight", player.Character)
v.Parent:FindFirstChild("Humanoid").AutoRotate = false
local knockbackdir = player.Character.HumanoidRootPart.CFrame.LookVector
local bg = Instance.new("BodyGyro")
bg.Parent = v.Parent:WaitForChild("HumanoidRootPart")
bg.D = 0
bg.P = 500000
bg.CFrame = CFrame.lookAt(v.Parent:WaitForChild("HumanoidRootPart").Position, knockbackdir)
local att = Instance.new("Attachment")
att.Parent = v.Parent:WaitForChild("HumanoidRootPart")
local vf = Instance.new("VectorForce")
vf.Parent = v.Parent:WaitForChild("HumanoidRootPart")
vf.Attachment0 = att
vf.Force = Vector3.new(0,5000,10000)
for index, joint in pairs(v.Parent:GetDescendants()) do
task.spawn(function() -- I put the SPAWN function here instead
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
joint.Enabled = false
task.wait(0.1)
v.Parent:FindFirstChild("Humanoid").AutoRotate = true
vf:Destroy()
bg:Destroy()
att:Destroy()
task.wait(0.75)
v.Parent:FindFirstChild("Humanoid").PlatformStand = false
v.Parent:FindFirstChild("Humanoid").WalkSpeed = 10
joint.Enabled = true
socket:Destroy()
end
end)
end
end)
Any help would be greatly appreciated.