title. I’ll start off by showing screenshots first:
Script inside the BlueBlock tool:
---------------------------------------------VARIBLES-------------------------------------------------
local remoteEvent = game.ReplicatedStorage:WaitForChild("BuildingSystemEvent")
local runService = game:GetService("RunService")
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local grid = 1.5
local blueBlock = game.ReplicatedStorage:WaitForChild("BlueBlock")
local shadow_block = blueBlock:Clone(); shadow_block.Transparency = .5; shadow_block.Parent = workspace.Blocks.ShadowBlocks; shadow_block.CanCollide = false
if shadow_block.CanCollide == true then
print("BRUH")
end
mouse.TargetFilter = shadow_block
---------------------------------------------FUNCTIONS-------------------------------------------------
function snapToGrid(x)
return math.floor(x/grid + 0.5)*grid
end
function calculateY(toP, toS, oS)
return (toP + toS * 0.5) + oS * 0.5
end
runService.RenderStepped:Connect(function()
if mouse.Target ~= nil then
shadow_block.Position = Vector3.new(snapToGrid(mouse.Hit.Position.X), calculateY(mouse.Target.Position.Y, mouse.Target.Size.Y, blueBlock.Size.Y), snapToGrid(mouse.Hit.Position.Z))
end
if tool:FindFirstAncestorWhichIsA("Model") ~= player.Character then
shadow_block.Transparency = 1
else
shadow_block.Transparency = .5
end
end)
tool.Activated:Connect(function()
if tool:FindFirstAncestorWhichIsA('Model') == player.Character then
print(shadow_block.Position)
remoteEvent:FireServer("blueBlock", shadow_block.Position)
print("script is working")
end
end)
Script inside the RedBlock tool:
---------------------------------------------VARIBLES-------------------------------------------------
local remoteEvent = game.ReplicatedStorage:WaitForChild("BuildingSystemEvent(redblock)")
local runService = game:GetService("RunService")
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local grid = 1.5
local red_block = game.ReplicatedStorage:WaitForChild("RedBlock")
local shadow_block = red_block:Clone(); shadow_block.Transparency = .5; shadow_block.Parent = workspace.Blocks.ShadowBlocks; shadow_block.CanCollide = false
if shadow_block.CanCollide == true then
print("ooooo")
end
mouse.TargetFilter = shadow_block
---------------------------------------------FUNCTIONS-------------------------------------------------
function snapToGrid(x)
return math.floor(x/grid + 0.5)*grid
end
function calculateY(toP, toS, oS)
return (toP + toS * 0.5) + oS * 0.5
end
runService.RenderStepped:Connect(function()
if mouse.Target ~= nil then
shadow_block.Position = Vector3.new(snapToGrid(mouse.Hit.Position.X), calculateY(mouse.Target.Position.Y, mouse.Target.Size.Y, red_block.Size.Y), snapToGrid(mouse.Hit.Position.Z))
end
if tool:FindFirstAncestorWhichIsA("Model") ~= player.Character then
shadow_block.Transparency = 1
else
shadow_block.Transparency = .5
end
end)
tool.Activated:Connect(function()
if tool:FindFirstAncestorWhichIsA('Model') == player.Character then
print(shadow_block.Position)
remoteEvent:FireServer("red_block", shadow_block.Position)
print("script is working")
end
end)
Server script in ServerScriptService
for the blue tool:
local remoteEvent = game.ReplicatedStorage:WaitForChild("BuildingSystemEvent")
remoteEvent.OnServerEvent:Connect(function(player, block, position)
print(position)
local clone = game.ReplicatedStorage:WaitForChild("BlueBlock"):Clone()
clone.Parent = workspace.Blocks.BlueBlocks
clone.Position = position
end)
Server script in ServerScriptService
for the red tool:
local remoteEvent = game.ReplicatedStorage:WaitForChild("BuildingSystemEvent(redblock)")
remoteEvent.OnServerEvent:Connect(function(player, block, position)
print(position)
local clone = game.ReplicatedStorage:WaitForChild("RedBlock"):Clone()
clone.Parent = workspace.Blocks.BlueBlocks
clone.Position = position
end)
- So, for some reason, they work fine when the other script in the other tool is disabled.
But, as shown in the video above, if they’re both active and both of their scripts are enabled, the y axis gets a little funky. - Also, after the first issue is resolved, another slight annoyance happens where, I can’t place the block on the side if it is in the air:
this is what the regular building indicator looks like:
PLEASE HELP
(If any screenshots can’t be viewed, try clicking on them to open it up.)