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

Can i get some help with vectors and velocity?

Im trying to get my "Bul2" to go up and forward at the same time, how can i do this?


local FG = script.Parent
local Handle = script.Parent
local Bul = game.ServerStorage.FlareBull

local function Onclick()
    local Bul2 = Bul:Clone()
	 Bul2.Position = Handle.Handle.Position
	 Bul2.Velocity = Handle.Handle.CFrame.XVector * (300)
	 Bul2.Velocity = Handle.Handle.CFrame.YVector * (300)
	 Bul2.Parent = workspace
wait(4)
    Bul2.Anchored = true
    Bul2.ParticleEmitter.Rate = 0
    Bul2.Transparency = 1
wait(10)
    Bul2:Destroy() 
end

FG.Activated:Connect(Onclick)

1 answer

Do note that BasePart.Velocity takes a Vector3. Lines 08 and 09 rewrite over each other and that results in the part moving in just one direction. You should just do Vector3.new(300,300,0).

3 comments

0

Then i can only shoot it one way?

0

One way as in one direction? No, you can shoot it in any combination of directions. But you want to move 300 studs up and 300 studs to the right per second and that's just a Vector of 300,300,0.

0

What you're doing in your script is that first you're making it go to the right, and then you're telling it to stop going to the right and making it go up.

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