I’m trying to make a hammer that would unanchor anchored rootParts when it get hit.
local tool = script.Parent
local head = tool.Handle
local remoteEvent = tool.RemoteEvent
local smash
remoteEvent.OnServerEvent:Connect(function(player, character, charged, magnitude)
local rootPart = character:FindFirstChild("HumanoidRootPart")
if charged then
smash = head.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local hitCharacter = hit.Parent
local hitRootPart = hitCharacter:FindFirstChild("HumanoidRootPart")
if humanoid then
local knockback = Instance.new("BodyVelocity")
hitRootPart.Anchored = false --here fella!
knockback.Parent = hitRootPart
knockback.Velocity = (rootPart.CFrame.LookVector * magnitude) + (rootPart.CFrame.UpVector * magnitude)
knockback.MaxForce = knockback.MaxForce * magnitude
wait()
knockback:Destroy()
end
end)
wait(0.3)
smash:Disconnect()
end
end)
Issue is, there are tests that it work and there are tests that it doesn’t. I’m really confused, please help me. Thanks much!