# How would I make an object fling?

1. What do you want to achieve? Keep it simple and clear!
I want to script a part to fling as if it were thrown.

2. What is the issue? Include screenshots / videos if possible!
Tweening is too linear and too perfect to make it look realistic so I can’t tween it.

3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I was thinking of using invisible explosions or rocket propulsion to make the part fling but they don’t work that well.

Basically I have a flashbang grenade and I want to make it fling and go forward so it can make a flash. This isn’t possible really but I have seen games use it.

5 Likes

Hmm, well there are definitely plenty of ways to achieve a fling which comes down to manipulating either the objects velocity or cFrame for more controlled paths.

Manipulating the velocity will automatically fling said object and relies on the roblox physics engine. I remember lots of early games on roblox like ‘build a raft down the river’ used this technique to achieve motion.

In any case a simple script such as:
`obj.Velocity=obj.Velocity + Vector3.new(0,50,100)`
can fling an obj adjusting the object’s speed along the y and z axis.
Some more on vector3’s:
https://developer.roblox.com/en-us/api-reference/datatype/Vector3
https://developer.roblox.com/en-us/articles/BodyMover

However, I assume you’ll meet some math calculations for determining how much to fling the object or in what direction.

So feel free to provide more details on how you want to activate the fling and what the direction is based off. Like if direction is based off a character clicking somewhere or its in the rotation of another object.

1 Like

It is simply a throw in the front of the player. I’ll experiment with Velocity real quickly.

You can always utilize a quadratic equation to create a fling arc. You’ll need to work with a few different things, which this article by EgoMoose should help you with.

Nice, if your still trying to figure it out, try this code:

``````local grenade=script.Parent	-- Object to fling
local power={100,50} 			-- Horizontal, vertical power on fling

function fling()
local torso=character:WaitForChild('HumanoidRootPart')	-- Object to base direction on
if not torso then	-- Check to make sure torso object exists
error('No part to take direction from')
end

-- Fling velocity Vector
local fling_vector= Vector3.new(