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

How do I make the shot face the same way it travels?

Asked by
neoG457 315 Moderation Voter
8 years ago
local Shot             = Instance.new("Part")
local Crystal          = Instance.new("SpecialMesh")
Crystal.MeshId         = "http://www.roblox.com/Asset/?id=9756362"
Crystal.Parent         = Shot
Crystal.Scale          = Vector3.new(0.50, 0.50, 3)
Shot.Transparency      = 0.5
Shot.Size              = Vector3.new(4, 4, 4)
Shot.BrickColor        = BrickColor.new("Eggplant")
Shot.Parent            = workspace
Shot.CanCollide        = false
local DMG              = game.ReplicatedStorage.ShardDMG:Clone()
DMG.Parent             = Shot

local Zoom             = Instance.new("BodyVelocity")
Zoom.maxForce          = Vector3.new(math.huge, math.huge, math.huge)
local speed            = 100
Zoom.velocity          = CFrame.new(Player.Character.Torso.CFrame.p, Mouse.Hit.p).lookVector * speed
Zoom.Parent            = Shot

So everything works fine but I need the shot to face the same way its traveling because it only faces the way my torso does. How do I rotate the shot to make it face the same way its traveling.

0
Is there more to the script you're not showing? I notice that you don't set the Position or CFrame of "Shot". chess123mate 5873 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You've already made the CFrame/orientation you need on line 17; just re-use it. Here's a rewrite of lines 17 onward:

local dir = (Mouse.Hit.p - Player.Character.Torso.Position).unit
Zoom.velocity = dir * speed
Shot.CFrame = CFrame.new(Shot.Position, Shot.Position + dir)
Zoom.Parent = Shot
0
Sorry didnt work. neoG457 315 — 8y
Ad

Answer this question