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

Having model face mouse, model flips sideways instead?

Asked by 8 years ago

I'm attempting to create a turret that will rotate in the direction of my mouse (But not rotating on the Y axis) however when running code for the turret (Which is a model) the turret will instead turn onto its side and the barrel will point to the sky, but will rotate in the direction of my mouse (As in the barrel is moving in a circle towards where my mouse is pointing but the model itself remains in the position).

I originally put my model in correctly, but the script may be causing my turret to rotate towards the air.

Code (In StarterPlayerScripts):

player = game.Players.LocalPlayer

Model = game.Workspace.Turret
Baser = game.Workspace.Turret.Base
Mouse = player:GetMouse()

Mouse.Move:connect(function()

    Model:SetPrimaryPartCFrame(CFrame.new(Baser.Position, Vector3.new(Mouse.Hit.p.x,4.,Mouse.Hit.p.z)))
end)

The above is the only code in the game. The 4 in the Vector3 Y is the Y dimensions of the turret.

Turret is a model, and Baser is a part inside the turret. Baser is the primary part, and another part, Barrel, is placed with part of itself inside the Baser (Having them separate as I will have the barrel tilt upward on the Y, at a later time).

0
What's the point of line 10? User#11440 120 — 8y
0
That's going to be removed soon, I forgot it was there. I'll remove it. godonan 0 — 8y
0
^ theCJarmy7 1293 — 8y

Answer this question