Why are the bullets in my gun not moving? The body velocity is in the bullet and it isn't anchored.
I just want to say that I made sure the part is unanchored.
I used remote events, so there are two scripts.
Server Script:
01 | local tool = script.Parent |
02 | local event = tool.ClickEvent |
03 | local handle = tool.Handle |
06 | local part = Instance.new( "Part" ) |
07 | part.Parent = workspace |
08 | part.Size = Vector 3. new(. 2 , . 2 , . 2 ) |
09 | part.BrickColor = BrickColor.Yellow() |
11 | part.CanCollide = false |
15 | event.OnServerEvent:connect( function (player, mouseLocation) |
16 | local part = createPart() |
17 | part.CFrame = tool.Handle.CFrame |
18 | part.CFrame = CFrame.new(part.Position, mouseLocation) |
19 | local bodyVelocity = Instance.new( "BodyVelocity" , part) |
20 | bodyVelocity.velocity = part.CFrame.lookVector * 90 |
21 | bodyVelocity.maxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
22 | game.Debris:AddItem(part, 15 ) |
Local Script:
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
04 | local tool = script.Parent |
05 | local event = tool.ClickEvent |
08 | tool.Activated:connect( function () |
09 | local mouseLocation = mouse.Hit.p |
10 | event:FireServer(mouseLocation) |