Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 answers

✓ Accepted answer

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)

1 comment

0

thanks, it helped so much!

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.