How do I get information about whether this particular "cell" is occupied? (client grid script)

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)

Heeeeelppppppppp pleeeeeeeeeeeaseeeeee

pls explain more what your script do and wym by cell.

I apologize for my terrible English. Here:
image
this green… somehing I named cell

You could add an attribute to the part with an owner tittle. Then in your script look for the attribute if it’s taken or empty.

1 Like

Good idea. I solved my problem by creating a matrix of zeros and ones

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.