How would i go about making a script where they cannot place blocks outside their island

You will get all of the islands if each player has their own local script handling their island

That error is likely due to you not implementing the fix I noted.
Replace

game.Workspace.Islands.Islands["ISLAND1"]

over

game.Workspace.Islands.Islands[ISLAND1]
1 Like

So do you want me to write it like this?

local boundPos = game:GetService("Workspace"):WaitForChild("Islands"):WaitForChild("Islands")["ISLAND1"/"ISLAND2"/"ISLAND3"/"ISLAND4"/"ISLAND5"/"ISLAND6"]

Not quite.
Only do the island that player owns. For testing purposes, just do

local boundPos = game:GetService("Workspace"):WaitForChild("Islands"):WaitForChild("Islands")["ISLAND1"]
1 Like

Ok, so the script KINDA works, I can still place blocks outside of the plot though, although i didnt make a server script that checks stuff.

This is what shows in output when i place something out of bounds:

Are you using the value that the function returns to check? Before you fire the remote event, do something like

if isMouseInBoundsOfPlot() == true then
       -//block placing code here
end

As I said, I dont have a script like that set up, could you please show me how?
Here’s the script to place the blocks ( I have 2 of these scripts, because I have one for placing blue blocks, and one for red ):
BLUE TOOL:

                                 ---------------------------------------------VARIBLES-------------------------------------------------
local remoteEvent = game.ReplicatedStorage:WaitForChild("BuildingSystemEvent(blueblock)")
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)

Server Script for the blue tool:


local remoteEvent = game.ReplicatedStorage:WaitForChild("BuildingSystemEvent(blueblock)")

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)

Script for the red 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 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.RedBlocks
	clone.Position = position
end)

I cant quite do this at the moment, I’m sure another person on the devforum would be willing to help

1 Like