How do I get information about whether this particular “cell” is occupied?
local Mouse = game.Players.LocalPlayer:GetMouse()
local Positiona
local Limit = 25
local part
local X
local Y
local Z
local cooldown = false
script.Parent.Activated:Connect(function()
if not cooldown then
cooldown = true
local distance = (Mouse.Hit.Position - script.Parent.Parent.HumanoidRootPart.Position).Magnitude
if distance < Limit then
script.Parent.place:FireServer(Positiona)
end
wait(0.2)
cooldown = false
end
end)
Mouse.Move:Connect(function()
local GridSize = 4
local gridX = math.floor(Mouse.Hit.X / GridSize) * GridSize + 2
local gridY = math.floor(Mouse.Hit.Y / GridSize + 0.5) * GridSize
local gridZ = math.floor(Mouse.Hit.Z / GridSize) * GridSize + 2
X = gridX
Y = gridY
Z = gridZ
Positiona = CFrame.new(X, Y, Z)
local target = Mouse.Target
if target then
local Normal = Mouse.TargetSurface
if Normal == Enum.NormalId.Bottom then
Positiona = Positiona + Vector3.new(0, -3, 0)
elseif Normal == Enum.NormalId.Right then
Positiona = Positiona + Vector3.new(3, 0, 0)
elseif Normal == Enum.NormalId.Back then
Positiona = Positiona + Vector3.new(0, 0, 3)
end
end
end)
script.Parent.Equipped:Connect(function()
part = game.ReplicatedStorage.Block:Clone()
part.Transparency = 0.5
part.Parent = workspace
while true do
if part then
part.CFrame = Positiona
end
wait()
end
end)
script.Parent.Unequipped:Connect(function()
part:Destroy()
end)
