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

Does not Snap to the same grid when rotate?

Asked by 3 years ago

When I rotate the wall its does not snap to the same gird as the other orientation

local player = game.Players.LocalPlayer
local mouse  = player:GetMouse()
local build = false
local uis = game:GetService("UserInputService")
local rot = 0

uis.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.R then
        rot = rot + 90
    end
end)

player.Backpack.Blueprint.Equipped:Connect(function()
    if player.Character.Blueprint.Value.Value ~= "" then
        part = game.ReplicatedStorage:FindFirstChild(player.Character.Blueprint.Value.Value.. "-Place"):Clone()
        mouse.TargetFilter = part

            if part then
                part.Parent = game.Workspace

                build = true
                while script.On.Value do
                wait(0.1)
                    if mouse.Target ~= nil then
                    if mouse.Target.Parent.Name ~= part.Name then
                        part:SetPrimaryPartCFrame(CFrame.new(math.round(mouse.Hit.X),mouse.Hit.Y+ part.PrimaryPart.Size.Y/2,math.round(mouse.Hit.Z))* CFrame.Angles(0,math.rad(rot),0))
                    end


                    if build == false then
                        break
                    end
                end
            end
        end
    end
end)


player.Backpack.Blueprint.Unequipped:Connect(function()
if part then
        build = false
        part:Destroy()
    end
end)

player.Backpack.Blueprint.Activated:Connect(function()
    if part then
        player.Character.Blueprint.RemoteEvent:FireServer(part:FindFirstChildOfClass("Part").Position, player.Character.Blueprint.Value.Value, mouse.Target,game.Workspace.Bases:FindFirstChild(player.Name).CFrame:ToObjectSpace(part.PrimaryPart.CFrame),rot)
    end 
end)

0
There is no such method of the math class called, 'round'. Ziffixture 6913 — 3y
0
You can probably just fix it by making the wall have integer sizes thecelestialcube 123 — 3y

Answer this question