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

Do these 2 lines do the exact same thing?

Is there any difference in between these 2 lines at line 9? both of them makes the bullet travel at 200 in the direction i am clicking.

 bodyvelocity.Velocity = CFrame.new(part.Position,mouse.Hit.Position).lookVector * 200
  bodyvelocity.Velocity = mouse.Hit.lookVector * 200

*part position is the position of the bullet.

full script:


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

mouse.Button1Down:Connect(function()
    print(CFrame.new(mouse.Hit.Position).lookVector *200)
    local part = Instance.new("Part", workspace)
    local bodyvelocity = Instance.new("BodyVelocity", part)
    bodyvelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    bodyvelocity.Velocity = mouse.Hit.lookVector * 200 -- this line
	part.CanCollide= false
	part.Position = plr.Character.Head.Position 
end)

4 comments

0

and no i dont think there is any difference

0

mouse.Hit.LookVector is the same as CFrame.new(RootPart.Position, mouse.Hit.Position).LookVector (correct me if I'm wrong) - so I think doing that is redundant.

0

Your script is from this page. https://scriptinghelpers.org/questions/82196

1 answer

✓ Accepted answer

No. That not same.

If you use this

bodyvelocity.Velocity = mouse.Hit.lookVector * 200

The CFrame will be located at player's character.

if you use this

bodyvelocity.Velocity = CFrame.new(part.Position,mouse.Hit.Position).lookVector * 200

The CFrame will be located at the part.

3 comments

0

whats the difference in that?

0

that mean if you use mouse.Hit and locate part to other position that not player character, it will not work 100%

0

Ex. if you click at the back, it will go forward

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