Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Do these 2 lines do the exact same thing?

Asked by 5 years ago
Edited 5 years ago

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)
0
and no i dont think there is any difference starmaq 1290 — 5y
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. pidgey 548 — 5y
0
Your script is from this page. https://scriptinghelpers.org/questions/82196 OnaKat 444 — 5y

1 answer

Log in to vote
2
Answered by
OnaKat 444 Moderation Voter
5 years ago

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.

0
whats the difference in that? Thepoint13 99 — 5y
0
that mean if you use mouse.Hit and locate part to other position that not player character, it will not work 100% OnaKat 444 — 5y
0
Ex. if you click at the back, it will go forward OnaKat 444 — 5y
Ad

Answer this question