I wanted a hammer that throw players away when it hit them.
This is how I attempted to do it. But it just won't work. There's nothing in the output, also. How to fix this? -Or is there a better way to achieve what I wanted? Please help. Thanks! :^)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = humanoid.RootPart
local tool = script.Parent
local debounce = false
local canDamage = script.Parent:WaitForChild("CanDamage")
tool.Activated:Connect(function()
if not debounce then
debounce = true
local attack = script.Attack
local attackTrack = humanoid:LoadAnimation(attack)
attackTrack:Play()
canDamage.Value = true
tool.Blade.Touched:Connect(function(hit)
print("hit")
if canDamage.Value == true then
canDamage.Value = false
local BodyForce = rootPart:FindFirstChild("BodyForce") or Instance.new("BodyForce", player:FindFirstChild("HumanoidRootPart"))
local Velocity = rootPart.CFrame.LookVector * -100
BodyForce.Force = Velocity
--hit.Parent.Humanoid:TakeDamage(20)
end
end)
wait(2)
debounce = false
end
end)
