How to make Chances

How to do Chances like 1/5 , 5/5, i am not sure if this uses math.random, because if it would do then it will be like this, math.random(1,5), I am correct?

1 Like

You are correct. You can also use Random: Random | Roblox Creator Documentation

1 Like

For example, this script will kick someone if math.random(1,100) doesn’t return 5:

--//Services
local Players = game:GetService("Players")

--//Functions
Players.PlayerAdded:Connect(function(Player)
	local Number = math.random(1,100)
	
	if Number ~= 5 then
		Player:Kick("You got " .. Number .. " instead of 5.")
	end
end)
1 Like

Mmmm, are you sure its not something like this?

local = 1/5 , isaw something like this before, but i dont know where and how

Variables have to have a name so that won’t work but instead throw an error.

“/” simply used to divide and im sure the script u saw used for the Chances math.Random and used “/” to divide a num

local PlayersService = game:GetService("Players")

--my version

PlayersService.PlayerAdded:Connect(function(Player)
   local Result = math.random(1,5)
local ValuePlace = Instance.new("NumberValue")
ValuePlace.Parent = Player
ValuePlace.Value = Result

if Result == 1 then
print(Player.."Got"..Result)
elseif Result == 2 then
print(Player.."Got"..Result)
elseif Result == 3 then
print(Player.."Got"..Result)
elseif Result == 4 then
print(Player.."Got"..Result)
elseif Result == 5 then
print(Player.."Got"..Result)
end
end)

--Feel free to use Valueplace as a value
1 Like

That is correct but You need to make a value into Player or ReplicatedStorage or Other for Store The Player Data i know if the player got the number already, so the number will not duplicated

if you are talkin to me, yes ill edit it