Issue:
https://gyazo.com/81cde2c53eda2c3e33d62d450562b06f
Happens at 0:05 You can see the unalignment.
Relevant code:
elseif BuildMode == true and key.UserInputType == Enum.UserInputType.MouseButton1 then
local parttheir = false
if mouse.Hit.Y >= plot.Position.Y + plot.Size.Y/2.0001 then
local pos = Vector3.new(math.floor(mouse.Hit.X/grid + 0.5)*grid,(plot.Position.Y*2)+(part.Size.Y/2),math.floor(mouse.Hit.Z/grid + 0.5)*grid) + add
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("UnionOperation") and v.Position.X == pos.X and v.Position.Z == pos.Z and not v:FindFirstChild("Value") then
parttheir = true
end
end
if parttheir == false and mouse.Target == plot then
game.ReplicatedStorage.BuildEvent:FireServer(part.Name,pos,currenty)
end
end
ServerCode
game.ReplicatedStorage.BuildEvent.OnServerEvent:Connect(function(plr,part,pos,orientationy)
local Part = game.ReplicatedStorage:FindFirstChild(part):Clone()
Part.Parent = game.Workspace
Part.Position = pos
Part.Orientation = Vector3.new(Part.Orientation.X,orientationy,Part.Orientation.Z)
Part:FindFirstChild("Value"):Destroy()
end)
game.ReplicatedStorage.RemoveEvent.OnServerEvent:Connect(function(plr,poopscoopernumber1)
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("UnionOperation") and v.Position == poopscoopernumber1 and not v:FindFirstChild("Value") then
v:Destroy()
end
end
end)
Entire thing
local tw = game:GetService("TweenService")
local mouse = game.Players.LocalPlayer:GetMouse()
local UIS = game:GetService("UserInputService")
local plot = game.Workspace:WaitForChild("Plot")
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local part
local BuildMode = false
local db = false
local Texture
local currenty = 0
local grid = 6
local rendersteps = game:GetService("RunService")
local add
local wasd
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.B and BuildMode == false then
gui.Building.FurnitureGui.Close.MouseButton1Click:Connect(function()
for i,v in pairs(gui.Building.FurnitureGui:GetChildren()) do
v.Visible = false
end
for i,v in pairs(gui.Building:GetChildren()) do
if v:IsA("TextButton") then
v.Visible = true
end
end
end)
BuildMode = true
Texture = game.ReplicatedStorage.Texture:Clone()
Texture.Parent = plot
gui.Building.Visible = true
for i,v in pairs(gui.Building:GetChildren()) do
if v:IsA("TextButton") then
v.Visible = true
end
end
gui.Building.Furniture.MouseButton1Click:Connect(function()
for i,v in pairs(gui.Building:GetChildren()) do
if v:IsA("TextButton") then
v.Visible = false
end
end
for i,v in pairs(gui.Building.FurnitureGui:GetChildren()) do
v.Visible = true
v.MouseButton1Click:Connect(function()
if part then
part:Destroy()
end
if game.ReplicatedStorage:FindFirstChild(v.Name) then
part = game.ReplicatedStorage:FindFirstChild(v.Name):Clone()
part.Transparency = 0.3
currenty = part.Orientation.Y
part.Parent = game.Workspace
mouse.TargetFilter = part
end
end)
end
end)
rendersteps.RenderStepped:Connect(function()
if mouse.Target == plot and mouse.Hit.Y >= plot.Position.Y + plot.Size.Y/2.0001 and part then
if part:FindFirstChild("Value").Value == true then
add = part.CFrame.LookVector * grid/2
else
add = Vector3.new()
end
tw:Create(part,TweenInfo.new(0.25),{Position = Vector3.new(math.floor(mouse.Hit.X/grid + 0.5)*grid,(plot.Position.Y*2)+(part.Size.Y/2),math.floor(mouse.Hit.Z/grid + 0.5)*grid)+add}):Play()
end
end)
elseif BuildMode == true and key.KeyCode == Enum.KeyCode.B then
BuildMode = false
gui.Building.Visible = false
part:Destroy()
Texture:Destroy()
for i,v in pairs(gui.Building.FurnitureGui:GetChildren()) do
v.Visible = false
end
elseif BuildMode == true and key.KeyCode == Enum.KeyCode.R then
if db == false then
db = true
currenty = part.Orientation.Y + 90
tw:Create(part,TweenInfo.new(0.25),{Orientation = part.Orientation + Vector3.new(0,90,0)}):Play()
task.delay(0.25, function()
db = false
end)
end
elseif BuildMode == true and key.UserInputType == Enum.UserInputType.MouseButton1 then
local parttheir = false
if mouse.Hit.Y >= plot.Position.Y + plot.Size.Y/2.0001 then
local pos = Vector3.new(math.floor(mouse.Hit.X/grid + 0.5)*grid,(plot.Position.Y*2)+(part.Size.Y/2),math.floor(mouse.Hit.Z/grid + 0.5)*grid) + add
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("UnionOperation") and v.Position.X == pos.X and v.Position.Z == pos.Z and not v:FindFirstChild("Value") then
parttheir = true
end
end
if parttheir == false and mouse.Target == plot then
game.ReplicatedStorage.BuildEvent:FireServer(part.Name,pos,currenty)
end
end
elseif BuildMode == true and key.UserInputType == Enum.UserInputType.MouseButton2 then
local pos = Vector3.new(math.floor(mouse.Hit.X/grid + 0.5)*grid,(plot.Position.Y*2)+(part.Size.Y/2),math.floor(mouse.Hit.Z/grid + 0.5)*grid) + add
print("ooga")
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("UnionOperation") and v.Position.X == pos.X and v.Position.Z == pos.Z and not v:FindFirstChild("Value") then
print("Poop")
game.ReplicatedStorage.RemoveEvent:FireServer(v.Position)
end
end
end
end)
Thank you for help in advance. You can ask me any questions and I will respond to you.