--hi - samet local serverstorage = game:GetService("ServerStorage") local powerups = serverstorage.PowerUps local strength = powerups.StrengthUps local defense = powerups.DefenseUps local spawnpoints = game.Workspace.PowerSpawns:GetChildren() local PowerUps = require(game.ServerScriptService.PowerUps) local StrengthTable = {} local DefenseTable = {} while true do wait(15) local randomNumber = math.random(1, #spawnpoints) local randomSpawn = spawnpoints[randomNumber] local strups = strength:GetChildren() local randomIndex = math.random(1, #strups) local strengthup = strength:FindFirstChild("StrengthUp"..randomIndex) local defenseup = defense:FindFirstChild("DefenseUp"..randomIndex) local clonedStr = nil local cloneddef = nil print(randomIndex) print(strups) print(strengthup) --Strength PowerUP AlreadyExistsValue=randomSpawn:FindFirstChild("AlreadyExists") local function StrengthFunction() local function StrengthSpawn() print ("absolutely works") local spawnDone = false for i,currentSpawnPoint in pairs(spawnpoints) do local SpawnedTrue = currentSpawnPoint:FindFirstChild("AlreadyExists") if SpawnedTrue then end if not SpawnedTrue and spawnDone==false then AlreadyExistsValue = Instance.new("BoolValue") AlreadyExistsValue.Name = "AlreadyExists" AlreadyExistsValue.Parent = currentSpawnPoint clonedStr = strengthup:Clone() local StrengthUpLevel=Instance.new("IntValue") StrengthUpLevel.Parent = clonedStr StrengthUpLevel.Value = randomIndex StrengthUpLevel.Name = "StrengthLevel" local WhichSpawnPoint = Instance.new("StringValue") WhichSpawnPoint.Value = tostring(currentSpawnPoint) WhichSpawnPoint.Name = "SpawnPoint" local WhichSpawnClone = WhichSpawnPoint:Clone() WhichSpawnClone.Parent = clonedStr clonedStr.Parent = game.Workspace table.insert(StrengthTable,clonedStr) spawnDone=true local DesiredY = currentSpawnPoint.Position.Y + 5 clonedStr.SPart.CFrame=currentSpawnPoint.CFrame * CFrame.Angles(math.rad(90),math.rad(0),math.rad(90)) + Vector3.new(0,5,0) game:GetService("CollectionService"):AddTag(clonedStr.SPart,"StrengthTween") end end wait(2) end local StrengthCoroutine = coroutine.create(StrengthSpawn) coroutine.resume(StrengthCoroutine) for i, v in pairs(StrengthTable) do local ExistingPowerUps = v:GetChildren() for i, part in pairs(ExistingPowerUps) do if part:IsA("BasePart") then part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local value = hit.Parent:FindFirstChild("PU") print("hi") local PowerUpsSpawn = v:FindFirstChild("SpawnPoint") if value and value.Value == "no" and humanoid and PowerUpsSpawn then local player = hit.Parent local Level = v:FindFirstChild("StrengthLevel").Value v:Destroy() game.Workspace.PowerSpawns[PowerUpsSpawn.Value]:FindFirstChild("AlreadyExists"):Destroy() PowerUps.StrengthUp(player,Level,10) end end end) end end end wait(1) end --Defense PowerUP local function DefenseFunction() local function DefenseSpawn() print ("absolutely works") local spawnDone = false for i,currentSpawnPoint in pairs(spawnpoints)do local SpawnedTrue = currentSpawnPoint:FindFirstChild("AlreadyExists") if SpawnedTrue then end if not SpawnedTrue and spawnDone==false then AlreadyExistsValue = Instance.new("BoolValue") AlreadyExistsValue.Name = "AlreadyExists" AlreadyExistsValue.Parent = currentSpawnPoint cloneddef = defenseup:Clone() local DefenseUpLevel=Instance.new("IntValue") DefenseUpLevel.Parent = cloneddef DefenseUpLevel.Value = randomIndex DefenseUpLevel.Name = "DefenseLevel" local WhichSpawnPoint = Instance.new("StringValue") WhichSpawnPoint.Value = tostring(currentSpawnPoint) WhichSpawnPoint.Name = "SpawnPoint" local WhichSpawnClone = WhichSpawnPoint:Clone() WhichSpawnClone.Parent = cloneddef cloneddef.Parent = game.Workspace table.insert(DefenseTable,cloneddef) spawnDone=true local DesiredY = currentSpawnPoint.Position.Y + 5 for i,powerup in pairs(cloneddef:GetChildren()) do if powerup:IsA("BasePart") or powerup:IsA("MeshPart") then powerup.CFrame = CFrame.new(currentSpawnPoint.Position.X,DesiredY,currentSpawnPoint.Position.Z) end end end end wait(2) end local defensecoroutine = coroutine.create(DefenseSpawn) coroutine.resume(defensecoroutine) for i, v in pairs(DefenseTable) do local ExistingPowerUps = v:GetChildren() for i, part in pairs(ExistingPowerUps) do if part:IsA("BasePart") or part:IsA("MeshPart") then part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local value = hit.Parent:FindFirstChild("PU") print("hi") local PowerUpsSpawn = v:FindFirstChild("SpawnPoint") if value and value.Value == "no" and humanoid and PowerUpsSpawn then local player = hit.Parent local Level = v:FindFirstChild("DefenseLevel").Value v:Destroy() game.Workspace.PowerSpawns[PowerUpsSpawn.Value]:FindFirstChild("AlreadyExists"):Destroy() PowerUps.DefenseUp(player,Level,10) end end end) end end end wait(1) end DefenseFunction() StrengthFunction() end