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

how do i make a player get flung when they touch a certain block?

Asked by 6 years ago

i need a player to get flung really far away once they touch a certain block.

2 answers

Log in to vote
0
Answered by 6 years ago

You can use BodyForce like i did in a minigame I made called "The Sweeper".

script.Parent.Touched:connect(function(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local B = Instance.new("BodyForce",hit.Parent.HumanoidRootPart)
B.Force = Vector3.new(3000,3000,5000) -- You can change the force however you want it to be.
end
end)
0
thanks, it helped so much! grroch6 2 — 6y
Ad
Log in to vote
0
Answered by
Bisoph 5
6 years ago

Try this:

script.Parent.Touched:Connect(function(hit)
    local root = hit.Parent:FindFirstChild('HumanoidRootPart')
    local player = game.Players:GetPlayerFromCharacter(root.Parent)
    if root and player then
        root.Anchored = true -- allow to change the part's velocity
        root.CFrame = CFrame.new(script.Parent.Position, root.Position).lookVector * 500
        root.Anchored = false -- allow the part to move
    end
end)

Answer this question