Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my case system only give one type of skin?

It's meant to insert a random skin into the inventory but it's only giving holiday crowns

Num = 0



function script.RemoteFunction:OnServerInvoke(id)
	math.randomseed(tick())
    Num = math.random(1,100)
	local Skin = "nil"
	if Num > 50 then
		Skin = "blue"
	else
		if Num > 10 then
			Skin = "Pirate"
		else
			Skin = "Holiday Crown"
		end
	end
	
	local Inv = game:GetService("DataStoreService"):GetDataStore("Inventory"):GetAsync(id)
	table.insert(Inv,Skin)
	game:GetService("DataStoreService"):GetDataStore("Inventory"):SetAsync(id,Inv)
	return Skin
end

2 answers

you add a remote event

1 comment

0

??? the problem is that the only skin being inserted is pirate

This happened to me once when I was experimenting with math.randomseed. I did this in command bar

math.randomseed(tick()) print(math.random(1,10)) --prints 3 all the time

You are only supposed to do math.randomseed before you do randoming. For example,

math.randomseed(tick())
function something(times)
	local times = times or 1
	if times > 20 then
		return
	end
	print(math.random(1, 10))
	something(times + 1)
end
something()

Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.