Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

it won't let me touched player that sent them flyng?

Asked by 3 years ago

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

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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)
Ad

Answer this question