Not sure if I may or may not be allowed to direct a post here, but here is the link

Basically, what my code does is that it generates a random suit for the player. But the 'random' part does not work. It's the same for every player upon arrival in the server. I've tried it numerous of times with 2 - 3 players, and it was always the same result. I have math.randomseed(tick()) in a separate script, but I've also tried it within the script but both doesn't seem to show any difference at all. I've done a few tests which can be found on that link. Here's my code:

local storage = game.ServerScriptService
local moduleScripts = game.ServerScriptService:WaitForChild('ModuleScripts')
local createSuit = require(moduleScripts:WaitForChild('CreateSuit'))

function GenerateRandomSuit()
	local suits = {}
	
	for _, v in pairs(game.ReplicatedStorage.Suits:GetChildren()) do
		table.insert(suits, v)
	end
	return suits[math.random(#suits)] -- Returns the same value every time
end

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		local suit = GenerateRandomSuit()
		createSuit(suit, player)
		
	end)
end)

1 comment

0

Help :'(