This spawns Items/Powerups around the map for players to collect to gain an advantage over other players.
Script:
--[ Variables
local ServerStorage = game.ServerStorage
local Assets = ServerStorage.Assets
local SpawnerItems = ServerStorage.SpawnerItems
--[ Tables
local Items = {}
--[ Functions & Events
for i,Item in pairs(SpawnerItems:GetChildren()) do -- Adds items to table
table.insert(Items,Item)
end
function randomCFrame(part) -- Gets random CFrame from part
local x = part.Size.X/2
local z = part.Size.Z/2
local rx = math.random(-x,x)
local rz = math.random(-z,z)
return part.CFrame*CFrame.new(rx,0,rz)
end
function randomItem() -- Chooses random Item and spawns it
local Picked = Items[math.random(#Items)]
local Cloned = Picked:Clone()
local Giver = Assets.Spawner:Clone()
local RandomCFrame = randomCFrame(workspace.Baseplate)
Cloned.Parent = Giver
Cloned.Handle.Anchored = true
Cloned.Handle.CFrame = Giver.Hold.CFrame*CFrame.new(0,0.5,0)
Giver.Parent = game.Workspace.ItemStorage
Giver:SetPrimaryPartCFrame(RandomCFrame*CFrame.new(0,Giver.PrimaryPart.Size.Y/2,0))
end
while wait(5) do
if table.getn(Items) > 0 then -- If there is more than one item in the items table
randomItem()
end
end

1 comment
Full Line 31: Giver:SetPrimaryPartCFrame(RandomCFrame*CFrame.new(0,Giver.PrimaryPart.Size.Y/2,0))