this is my script from befopre: local CoreEvent = game.ReplicatedStorage:WaitForChild("CoreEvent")
local NPCFolder = game.ServerStorage:WaitForChild("NPCFolder")
-- Handle base locking
for i, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Owner") then
local Base = v
Base.LockBase.Touched:Connect(function(hit)
if hit.Parent.Name == Base.Owner.Value and Base.LockBase.IsLocked.Value == false then
Base.LockBase.IsLocked.Value = true
CoreEvent:FireAllClients("LockBase", Base)
task.delay(60, function()
Base.LockBase.IsLocked.Value = false
end)
end
end)
end
end
game.Players.PlayerAdded:Connect(function(plr)
for i, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Owner") and v.Owner.Value == "None" then
v.Owner.Value = plr.Name
v.Sign.SignGUI.SignTextLabel.Text = plr.Name .. "'s Base"
break
end
end
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local Steals = Instance.new("NumberValue")
Steals.Name = "Steals"
Steals.Value = 0
Steals.Parent = leaderstats
local Rebirths = Instance.new("NumberValue")
Rebirths.Name = "Rebirths"
Rebirths.Value = 0
Rebirths.Parent = leaderstats
local Cash = Instance.new("NumberValue")
Cash.Name = "Cash"
Cash.Value = 100
Cash.Parent = leaderstats
local OwnedUnits = Instance.new("Folder")
OwnedUnits.Name = "OwnedUnits"
OwnedUnits.Parent = plr
plr.CharacterAdded:Connect(function(Character)
for i, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Owner") and v.Owner.Value == plr.Name then
Character:PivotTo(v.Spawner.CFrame)
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local Base = nil
for i, v in ipairs(workspace:GetChildren()) do
if v:FindFirstChild("Owner") and v.Owner.Value == plr.Name then
Base = v
Base.Owner.Value = "None"
Base.Sign.SignGUI.SignTextLabel.Text = "Empty Base"
end
end
if Base then
for i,v in ipairs(Base:GetChildren()) do
if string.find(v.Name, "Platform") then
local Platform = v
Platform.CurrentUnit.Value = "None"
Platform.Collector.CollectorGUI.CollectTextLabel.text = ""
Platform.Collector.CollectorGUI.MoneyTextLabel.text = ""
if Platform:FindFirstChild("Rig") then
Platform.Rig.Status.Value = "Inactive"
task.wait(1)
Platform.Rig:Destroy()
end
end
end
end
end)
-- NPC setup
local NPCS = {
{model = NPCFolder:WaitForChild("Zombie"), Chance = 95},
{model = NPCFolder:WaitForChild("Red Eyed Zombie"), Chance = 95},
{model = NPCFolder:WaitForChild("Blue Zombie"), Chance = 95},
{model = NPCFolder:WaitForChild("Purple Zombie"), Chance = 95},
{model = NPCFolder:WaitForChild("Demon Zombie"), Chance = 85},
{model = NPCFolder:WaitForChild("Ice Zombie"), Chance = 85},
{model = NPCFolder:WaitForChild("Headless Zombie"), Chance = 85},
{model = NPCFolder:WaitForChild("Cone Zombie"), Chance = 85}
}
local function ChooseRandomNPC()
local TotalWeight = 0