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

Why is this grid placement system 1x1?

Asked by 6 years ago

This is a script that allows you to place block where ever you want them to be at be i want the gridstuds to be 4x4 not 1x1 but i don't know why it is 1x1 tried to change it but can't figure it out.

Heres the script + it is a localscript located in the startergui:

game:GetService("RunService").RenderStepped:connect(function()
    if Selected then

        local PlaceCFrame, X,Y,Z = nil, (Selected.Hitbox.Size.Z/2)%1, Selected.Hitbox.Size.Y/2, (Selected.Hitbox.Size.X/2)%1
        local p = ((CFrame.new(Mouse.hit.p, Camera.CFrame.p)*CFrame.new(0,0,-0.1))).p

        if Rotation0 == 0 then X,Z = (Selected.Hitbox.Size.X/2)%1, (Selected.Hitbox.Size.Z/2)%1 end

        Selected:SetPrimaryPartCFrame(CFrame.new(math.floor(p.X)+X,math.floor(p.Y+Y),math.floor(p.Z)+Z)*CFrame.Angles(0,math.rad(Rotation), math.rad(Toration)))
    end
end)

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

I found your answer on a previous question.

local grid = 4
game:GetService("RunService").RenderStepped:connect(function()
    if Selected then

        local PlaceCFrame, X,Y,Z = nil, (Selected.Hitbox.Size.Z/2)%1, Selected.Hitbox.Size.Y/2, (Selected.Hitbox.Size.X/2)%1
        local p = CFrame.new(Vector3.new( (Mouse.Hit.x+(grid/2)) - (Mouse.Hit.x+(grid/2))%grid, Mouse.Hit.y, (Mouse.Hit.z+(grid/2)) - (Mouse.Hit.z+(grid/2))%grid, Camera.CFrame.p))*CFrame.new(0,0,-0.1).p

        if Rotation0 == 0 then X,Z = (Selected.Hitbox.Size.X/2)%1, (Selected.Hitbox.Size.Z/2)%1 end

        Selected:SetPrimaryPartCFrame(CFrame.new(math.floor(p.X)+X,math.floor(p.Y+Y),math.floor(p.Z)+Z)*CFrame.Angles(0,math.rad(Rotation), math.rad(Toration)))
    end
end)
0
If i want "Y" to be the same grid how would i do that? ObStactionD3stroy3r 14 — 6y
0
follow the pattern used in my answer Azarth 3141 — 6y
Ad

Answer this question