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)

2 comments

0

There is no such method of the math class called, 'round'.

0

You can probably just fix it by making the wall have integer sizes