The random choosing is still selecting one place

Hello!
I was coding game named “Shoot the noob”
But when noob died then will spawn a new at random location but there is problem
It is still spawing on same place unless there is more than 10 spawns that can choose
Script:

game.Workspace.Noobs.ChildRemoved:Connect(function(noob)
	local Clone = game.ServerStorage.Noob:Clone()
	Clone.Parent = workspace.Noobs
	local Folder = game.Workspace.Spawners:GetChildren()
	Clone.HumanoidRootPart.Position = Folder[math.random(1,#Folder)].Position

end)

Thank for any help.

Try debugging it

local value = math.random(1, #Folder);
print(value, Folder[value], Folder[value].Position, #Folder);
Clone.HumanoidRootPart.Position = Folder[value].Position;

What does it print, does this print the same value everytime?

In a very rare cases (and perhaps not the case), it’s a coincidence that they’re all the same value.

Yep is spawning at same position

You can have a math.randomseed(tick()) to initiate true randomness. Also, try using after the folder before indexing a random part.

math.randomseed(tick())
game.Workspace.Noobs.ChildRemoved:Connect(function(noob)
	local Clone = game.ServerStorage.Noob:Clone()
	Clone.Parent = workspace.Noobs
	local Folder = game.Workspace.Spawners:GetChildren()
        local randomNumber = math.random(#Folder)
	Clone.HumanoidRootPart.Position = Folder[randomNumber].Position
        print(randomNumber) -- See if this number is different each time
end)
1 Like

Well I recorded what iss it doing but no progress
Dropbox - File Deleted - Simplify your life