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

How do I make a part shoot to the players position using bodyvelocity?

Asked by 5 years ago
Edited 5 years ago

function check() for _, v in pairs(game.Players:GetPlayers()) do if v.Character then if (v.Character.HumanoidRootPart.Position - script.Parent.Position).magnitude < 10 then return v end end end end while wait(0.1) do local human = check() if human ~= nil then local bullet = Instance.new("Part") bullet.CanCollide = false bullet.Position = script.Parent.Position local BV = Instance.new("BodyVelocity") BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BV.Velocity = human.Character.HumanoidRootPart.Position bullet.Parent = workspace BV.Parent = bullet end end

My code doesn't work properly. It doesn't shoot to where the humanoidrootpart is, how would i fix this?

0
I believe you should change line 19 to BV.Velocity = human.Character.HumanoidRootPart.CFrame.lookVector * 50 DesignerOfGames -7 — 5y
0
no, that will only shoot in the direction the player is looking. goodadmins 111 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Tricky stuff, that's how I did this in one of my CIWS scripts.

blt.BodyVelocity.Velocity = (Mouse.hit.p - workspace.Upper.Fire.Position).unit * 1200

Mouse.hit.p being the target the bullet will be shooting towards, the workspace.Upper.Fire.Position being the start position, .unit * 1200 actually doing all of the magic and adjusting the speed of the thing.

0
I meant, the bullets are coming from a part. Theres no mouse involved. goodadmins 111 — 5y
0
You can probably strip the Mouse.hit.p and see if anything happens Ashley_Phantom 372 — 5y
Ad

Answer this question