TYCOON
Plot Claim
Paste into ServerScriptService as a Script. Each model named Plot needs a part named Claim. The first player to touch Claim owns that plot, and their name appears above it.
-- Paste into ServerScriptService as a Script.
-- Each claimable plot is a Model named "Plot" with a part named "Claim" inside.
local Players = game:GetService("Players")
local owners: { [Model]: Player } = {}
local function labelClaim(claim: BasePart, text: string)
local existing = claim:FindFirstChild("OwnerBillboard")
if existing then
existing:Destroy()
end
local billboard = Instance.new("BillboardGui")
billboard.Name = "OwnerBillboard"
billboard.Size = UDim2.fromOffset(220, 40)
billboard.StudsOffset = Vector3.new(0, 4, 0)
billboard.AlwaysOnTop = true
billboard.Parent = claim
local label = Instance.new("TextLabel")
label.Size = UDim2.fromScale(1, 1)
label.BackgroundTransparency = 1
label.Text = text
label.TextColor3 = Color3.fromRGB(255, 255, 255)
label.Font = Enum.Font.GothamBold
label.TextScaled = true
label.Parent = billboard
end
for _, inst in ipairs(workspace:GetDescendants()) do
if inst:IsA("Model") and inst.Name == "Plot" then
local claim = inst:FindFirstChild("Claim", true)
if claim and claim:IsA("BasePart") then
labelClaim(claim, "Unclaimed")
claim.Touched:Connect(function(hit)
if owners[inst] then
return
end
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player then
return
end
for _, owner in pairs(owners) do
if owner == player then
return
end
end
owners[inst] = player
inst:SetAttribute("OwnerUserId", player.UserId)
labelClaim(claim, player.DisplayName)
end)
end
end
end
Players.PlayerRemoving:Connect(function(player)
for plot, owner in pairs(owners) do
if owner == player then
owners[plot] = nil
plot:SetAttribute("OwnerUserId", nil)
local claim = plot:FindFirstChild("Claim", true)
if claim and claim:IsA("BasePart") then
labelClaim(claim, "Unclaimed")
end
end
end
end)