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

Grid Placement system, Model Tilted Sideways?

Asked by 4 years ago
Edited 4 years ago

Hello,

I have recently been making a grid placement system but for some reason, the models are sideways and I can't figure out why.

The models aren't sideways when in edit mode but when I play it goes sideways.

https://gyazo.com/ae6452dfe1f252967c7ce9a507ea1844

Code:

local mouse = game.Players.LocalPlayer:GetMouse()
local Model = workspace:WaitForChild('ManaquinPose1')
local posX = mouse.Hit.X
local posY = mouse.Hit.Y
local posZ = mouse.Hit.Z
local gridSize = 1
local Rot = 0

local function rotate()
    Rot = Rot + 45
    Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(Rot), 0))
end

mouse.KeyDown:connect(function(key)
    if key == "r" then
    rotate()
    end
end)

local function Snap()
    posX = math.floor(mouse.Hit.X / gridSize + 0.5) * gridSize
    posY = mouse.Hit.Y
    posZ = math.floor(mouse.Hit.Z / gridSize + 0.5) * gridSize
end

mouse.Move:Connect(function()
    if mouse.Target.Name == 'Floor' then
        Snap()
        Model:SetPrimaryPartCFrame(CFrame.new(posX, posY + 3.3, posZ))
            Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(Rot), 0))
        mouse.TargetFilter = Model
    end
end)

local function Place()
    if mouse.Target.Name == 'Floor' then
    local WindowCopy = game:GetService('ReplicatedStorage').Objects.ManaquinPose1:Clone()
    WindowCopy.Parent = workspace
    WindowCopy:SetPrimaryPartCFrame(CFrame.new(posX, posY + 3.3, posZ) * CFrame.Angles(0, math.rad(Rot), 0))
    mouse.TargetFilter = WindowCopy
    end
end

mouse.Button1Down:Connect(function()
    Place()
end)

Thanks!

0
it might be fixable by changing one of the zeros on line 30 into "math.pi/2" mybituploads 304 — 4y

Answer this question