Hi. I'm trying to make the enemy push back the player. But for some reason whenever I add wait(1) it just stops working. How can I fix this? Thanks in advance.
Here's the enemy knockback script:
part = script.Parent
local h
function onTouch(hit)
h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
hit.Parent.HumanoidRootPart.Velocity = part.CFrame.lookVector * 100
end
end
part.Touched:connect(onTouch)
With wait(1):
part = script.Parent
local h
function onTouch(hit)
h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
wait(1)
hit.Parent.HumanoidRootPart.Velocity = part.CFrame.lookVector * 100
end
end
part.Touched:connect(onTouch)
