Untitled
unknown
plain_text
a year ago
4.9 kB
18
Indexable
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
-- Map each base to its spawn and sign
local bases = {}
local spawnFolder = Workspace:FindFirstChild("SpawnLocations")
if not spawnFolder then
warn("SpawnLocations folder not found in Workspace!")
else
print("Found SpawnLocations folder")
end
for i = 1, 8 do
local baseModel = Workspace:FindFirstChild("rebirth 1 base " .. i)
if baseModel then
-- Try different possible names for the sign parts
local signPart = baseModel:FindFirstChild("sign " .. i) or -- "sign 1", "sign 2", etc.
baseModel:FindFirstChild("Sign " .. i) or -- "Sign 4", etc.
baseModel:FindFirstChild("sign" .. i) -- fallback to "sign1", etc.
local spawnPart = spawnFolder and spawnFolder:FindFirstChild("spawn" .. i)
if signPart and spawnPart then
table.insert(bases, {
model = baseModel,
spawn = spawnPart,
sign = signPart,
owner = nil
})
print("Successfully loaded base " .. i .. " with sign: " .. signPart.Name)
else
warn("Missing spawn or sign for " .. baseModel.Name)
if not signPart then
warn(" - Could not find sign part (tried: 'sign " .. i .. "', 'Sign " .. i .. "', 'sign" .. i .. "')")
end
if not spawnPart then
warn(" - Missing 'spawn" .. i .. "' part in SpawnLocations folder")
end
end
else
warn("Missing base model: rebirth 1 base " .. i)
end
end
print("Total bases loaded: " .. #bases)
-- Helper function to update the TextLabel inside a sign
local function updateSign(signPart, text)
local gui = signPart:FindFirstChildOfClass("SurfaceGui")
if gui then
local label = gui:FindFirstChildOfClass("TextLabel")
if label then
label.Text = text
-- Make text bigger and add black outline
label.TextScaled = true -- Auto-scale text to fit
label.TextSize = 48 -- Base text size
label.TextStrokeTransparency = 0 -- Make outline visible
label.TextStrokeColor3 = Color3.new(0, 0, 0) -- Black outline
label.Font = Enum.Font.SourceSansBold -- Bold font for better readability
print("Updated sign to: " .. text)
else
warn("No TextLabel found in SurfaceGui")
end
else
warn("No SurfaceGui found on sign part")
end
end
-- Reset all bases to "Empty Base" at the start
for _, base in ipairs(bases) do
base.owner = nil
updateSign(base.sign, "Empty Base")
end
-- Check if player already has a base
local function getPlayerBase(player)
for _, base in ipairs(bases) do
if base.owner == player then
return base
end
end
return nil
end
-- Assign player to the first free base
local function assignBase(player)
-- Check if player already has a base
local existingBase = getPlayerBase(player)
if existingBase then
print("Player " .. player.Name .. " already has a base")
return existingBase
end
-- Find first free base
for _, base in ipairs(bases) do
if base.owner == nil then
base.owner = player
updateSign(base.sign, player.Name)
print("Assigned base to player " .. player.Name)
return base
end
end
warn("No free bases for player " .. player.Name)
return nil
end
-- Free up a base when player leaves
local function freeBase(player)
for _, base in ipairs(bases) do
if base.owner == player then
base.owner = nil
updateSign(base.sign, "Empty Base")
print("Freed base for player " .. player.Name)
break
end
end
end
-- Handle player joining
Players.PlayerAdded:Connect(function(player)
print("Player joined: " .. player.Name)
-- Assign base when player joins
local assignedBase = assignBase(player)
-- Handle character spawning
player.CharacterAdded:Connect(function(character)
if assignedBase then
-- Wait for character to fully load
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Teleport player to their base spawn
humanoidRootPart.CFrame = assignedBase.spawn.CFrame + Vector3.new(0, 5, 0)
print("Teleported " .. player.Name .. " to their base")
end
end)
end)
-- Handle player leaving
Players.PlayerRemoving:Connect(function(player)
print("Player left: " .. player.Name)
freeBase(player)
end)Editor is loading...
Leave a Comment