Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --building v2 test--
- plr = owner
- char = plr.Character
- mouse = plr:GetMouse()
- Mouse = mouse
- function SnapToGrid(x, gridX)
- local x = math.floor((x / gridX) + 0.5) * gridX
- return x
- end
- mouse.Button1Down:connect(function()
- if mouse.Target then
- local target = mouse.Target
- local block = Instance.new("Part",workspace)
- block.Anchored = true
- local x = Mouse.Target.CFrame.p.X
- local y = Mouse.Target.CFrame.p.Y
- local z = Mouse.Target.CFrame.p.Z
- if Mouse.TargetSurface.Name == "Right" then x = x + 2.6 end
- if Mouse.TargetSurface.Name == "Left" then x = x - 2.6 end
- if Mouse.TargetSurface.Name == "Top" then y = y + 2.6 end
- if Mouse.TargetSurface.Name == "Bottom" then y = y - 2.6 end
- if Mouse.TargetSurface.Name == "Back" then z = z + 2.6 end
- if Mouse.TargetSurface.Name == "Front" then z = z - 2.6 end
- -- local y = round(math.abs(mouseY)/2.6)*2.6
- -- local z = round(math.abs(mouseZ)/2.6)*2.6
- -- if Mouse.Hit.p.X < 0 then x = x * -1 end
- -- if Mouse.Hit.p.Y < 0 then y = y * -1 end
- -- if Mouse.Hit.p.Z < 0 then z = z * -1 end
- block.Size = Vector3.new(4, 4, 4)
- block.CFrame = CFrame.new(SnapToGrid(x, 4), SnapToGrid(y, 4), SnapToGrid(z, 4))
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement