function onTouched(hit) wait(0.0001) local DB = false if (DB == false) then DB = true local human = hit.Parent:FindFirstChild("Enemy") human.Health = human.Health - 1 local BV = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart) BV.Velocity = script.Parent.Parent.UpperTorso.CFrame.lookVector * 200 + game.Debris:AddItem(BV,1.5) wait(1) end end script.Parent.Touched:Connect(onTouched) return
✓ ANSWER ACCEPTED
it won't let me touched player that sent them flyng?
1 answer
✓ Accepted answer
script.Parent.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("HumanoidRootPart") == nil then return end --Make sure HRP exists
local HRP = touch.Parent:FindFirstChild("HumanoidRootPart") -- HumanoidRootPart
local Humanoid = touch.Parent:FindFirstChild("Humanoid") -- Humanoid
Humanoid.Sit = true -- Makes the player sit
local BodyVelocity = Instance.new("BodyVelocity", HRP) -- Creates a new BodyVelocity force inside HRP
BodyVelocity.Velocity = Vector3.new(0,200,0) -- Sets velocity, you can change this up depending on what direction you want the player to go to in.
wait(1)
BodyVelocity:Destroy() -- Deletes the force, making the player start to come back down.
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
