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

Moving a projectile with a curve?

I want to make it travel at a slight curve, see the image attached, and in the direction which it is facing, I don't know how to do that can someone help me?

I got it to do the curve I wanted, but it only goes in one direction https://gyazo.com/b9ae87b361d0b2c909f7d03e87b8d048

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
	local f = game.ReplicatedStorage.Flare:Clone()
	f.Parent = workspace
	f.CFrame = script.Parent.Parent:WaitForChild("HumanoidRootPart").CFrame + Vector3.new(0,5,0)
end)

2 answers

✓ Accepted answer

This is messy because you're using CFrame and Position and Orientation. This is not needed because CFrame is position and orientation.

local mouse = game.Players.LocalPlayer:GetMouse()
local TweenService = game:GetService("TweenService")

local goal = {}
goal.Position = Vector3.new(f.CFrame.upVector*250 + f.CFrame.lookVector*500)

local tweenInfo = TweenInfo.new(
	3, -- Time it takes to tween (I think)
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	0, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

mouse.Button1Down:Connect(function()
    local humanoidrootpart = script.Parent.Parent:WaitForChild("HumanoidRootPart")
    local f = game.ReplicatedStorage.Flare:Clone()
    f.Parent = workspace
    f.CFrame = CFrame.new(humanoidrootpart.Position,humanoidrootpart.Position) +
Vector3.new(0,5,0)

	TweenService:Create(f,tweenInfo,goal) -- Try this, it goes up 250 studs and forward 500 studs in 3 seconds

end)

Note: This might not fix it, it just makes it cleaner. Edit: You can achieve what you want to do with tween service I believe.

10 comments

0

Thank you, it looks a lot nicer to look at now

0

Also, what exactly is the issue, I couldn't understand your original post very well.

0

If there isn't an issue what do you want to achieve

0

Right now it spawns in were i want it to, i was it to go up 250 studs and forward 500 studs, creating the arc, from where the player is facing

0

can you potentially tween it?

0

I tried that but i just cant seem to get it right

0

I changed the code try it

0

I got "Uable to cast to Dictionary" Which is what i got earlier also

0

Try now

0

Now its just not tweening, i can mess with it and try to get it to fix

So i got it to work, doesnt look how i want it to so ima mess with it more, but here is the code

local mouse = game.Players.LocalPlayer:GetMouse()
local TweenService = game:GetService("TweenService")

mouse.Button1Down:Connect(function()
	local f = game.ReplicatedStorage.Flare:Clone()
	local humanoidrootpart = script.Parent.Parent:WaitForChild("HumanoidRootPart")
	f.Parent = workspace
	local goal = {}
	f.Orientation = humanoidrootpart.Orientation
	f.Position = humanoidrootpart.Position
	goal.Position = f.CFrame.LookVector * 500 + f.CFrame.UpVector * 250
	
	local tweenInfo = TweenInfo.new(
		3, -- Time it takes to tween (I think)
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)
	
   

    local tween = TweenService:Create(f,tweenInfo,goal) -- Try this, it goes up 250 studs and forward 500 studs in 3 seconds
	tween:Play()
	wait(2)
	f.Anchored = false
	f.Velocity = f.Velocity * 1
end)

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