How would I make a random detail occur when a RemoteEvent is fired?

as the title says, I want something random to appear on my map every time a RemoteEvent called resetEverythingInGame is fired.

how can I make it so that multiple functions can fire at a random probability?

1 Like

Try this out:

local randomEventsThatCouldHappen = {
	"another",
	"random",
	"somehih",
	"wwwq",
	"iueouioerwiouw"
}
local rand = Random.new()

replicatedStorage.resetEverythingInGame.OnServerEvent:Connect(function(plr)
	local rad = randomEventsThatCouldHappen[rand:NextInteger(1, #randomEventsThatCouldHappen)]
	print(rad)
end

cool. that’s a start. i was very vague in my saying, sorry for that.
how could i make it so that a function would be carried out by chance?

1 Like

Here’s an example:

local RS = game:GetService("ReplicatedStorage")

local rand = Random.new()

local function Func1()
	warn("test1")
end
local function Func2()
	warn("test2")
end
local function Func3()
	warn("test3")
end

local choices = {Func1, Func2, Func3}
local event = RS.resetEverythingInGame

event.OnServerEvent:Connect(function(player: Player)
	choices[rand:NextInteger(1, #choices)]()
end)

whoops, forgot to mark this as the solution. thanks a lot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.