How would I make a building system, where if you press the ImageButton
, you can place blocks, but it doesn’t place blocks when you press the button, it gives you ONLY the ability to place blocks, and if you want to stop placing blocks, you press the image button again to lose that ability.
Another I want, is when you enter this building gui, it stops your character from moving, and when the ability of placing blocks is on, the camera is freeroam. And when you close the building gui, the camera returns to normal, and you can move your character again.
Lastly, I want it so you can’t place blocks outside your plot.
Here are the scripts and gui:
Plot Script:
local plr = game:GetService("Players").LocalPlayer
local islands = game:GetService("Workspace").Islands.Islands
local island = islands:GetChildren()
local freeIslands = {}
for i, island in pairs(islands:GetChildren()) do
if island.Occupant.Value == nil then
table.insert(freeIslands, island)
end
end
for i,v in pairs(island) do
v.Touched:Connect(function(otherPart)
local character = otherPart:FindFirstAncestorOfClass("Model")
if character then
-- check if player already claimed an island
for i, v in pairs(islands:GetChildren()) do
if v.Occupant.Value == character.Name then
return -- stop if name is found
end
end
-- the rest of this code will not run if function returns
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(character);
v.Occupant.Value = plr.Name
end
end
end)
end
Gui:
Thank you for reading this, and have a good day.