Hey, the error says [ServerScriptService.Gems_Spawn:9: wrong number of arguments]
Please help if you can!
Code:
local s1 = game.Workspace.Spawn
local s2 = game.Workspace.Spawn2
local s3 = game.Workspace.Spawn3
local s4 = game.Workspace.Spawn4
local gem = game.ServerStorage.Gems['Stage-1'].Gem
local r = 10
while wait(1) do
local gemclone = gem:Clone()
local spawner = math.random(s1,s2,s3,s4) --line 9
local x,z = spawner.Position.X,spawner.Position.Z
x,z = math.random(x - r,x + r),math.random(z - r,z + r)
local pos = Vector3.new(x,spawner.Position.Y,z)
gemclone.Parent = workspace.Gems
gemclone.Position = pos
end
local spawns = {
game.Workspace.Spawn,
game.Workspace.Spawn2,
game.Workspace.Spawn3,
game.Workspace.Spawn4,
}
local spawner = spawns[math.random(1, #spawns)]
local gem = game.ServerStorage.Gems['Stage-1'].Gem
local r = 10
while wait(1) do
local gemclone = gem:Clone()
local x,z = spawner.Position.X,spawner.Position.Z
x,z = math.random(x - r,x + r),math.random(z - r,z + r)
local pos = Vector3.new(x,spawner.Position.Y,z)
gemclone.Parent = workspace.Gems
gemclone.Position = pos
end
I am verifying I did it properly, as I am testing it right now
You should move local spawner = spawns[math.random(1, #spawns)] inside the while-loop, otherwise you’ll only be choosing it once. In the original script, it seemed like choosing one of the 4 spawners every loop is what you wanted to do.