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

Setting a projectile's rotation?

Asked by 7 years ago

Hi, I'm trying to create a gun that fires cylinder-shaped projectiles. I want the projectiles to be rotated in a way that the ends are facing downwards and not side to side.

player = game.Players.LocalPlayer
weapon = script.Parent
mouse = player:GetMouse()
function shoot()
    local laser = Instance.new("Part", workspace)
    laser.Shape = "Cylinder"
    laser.CanCollide = false
    laser.Size = Vector3.new()
    laser.BottomSurface = "Smooth"
    laser.BackSurface = "Smooth"
    laser.FrontSurface = "Smooth"
    laser.LeftSurface = "Smooth"
    laser.RightSurface = "Smooth"
    laser.TopSurface = "Smooth"
    laser.Rotation = Vector3.new( 0, 0, 90)
    laser.CFrame = weapon.Handle.CFrame
    laser.CFrame = CFrame.new(laser.Position,mouse.Hit.p)
    v = Instance.new("BodyVelocity", laser)
    v.Velocity = laser.CFrame.lookVector *90
    v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
end
weapon.Activated:connect(shoot)

Even though I set the projectile's rotation, the rotation is still way off when it's fired.

0
CFrame is Position and rotation. Try moving line 15 below line 17. User#11440 120 — 7y

1 answer

Log in to vote
-1
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

Sorry for not explaining much, I am on my pad but maybe use CFrame.Angles(). Look it up, hope it helps.

0
P-put a link on that topic!!! StoIid 364 — 7y
Ad

Answer this question