Help making a role chooser inspired by "Where's the Baby!"

Hi developers,

I’m making a game inspired by “Where’s the Baby!” And i need help on making a role chooser when the game starts.

I know that this has somewhat to do with events or bindable ones, otherwise we can pretty much… never do it. But i need help on choosing the parents and the babies (or kids). Anyone can help me?

(Yes i already have the round system:)

local CountdownEvent = game:GetService("ReplicatedStorage"):WaitForChild("Countdown")
local Status = game.ReplicatedStorage:WaitForChild("Status")
local Maps = game:GetService("ReplicatedStorage"):WaitForChild("Maps"):GetChildren()

function Time()
	for i = 60, 1, -1 do
		Status.Countdown.Value = i
		task.wait(1)
	end
end

function MainFunction()
	local PlayersAmount = #game:GetService("Players"):GetPlayers()
	
	--if PlayersAmount >= 1 then
		local RandomMap = Maps[math.random(1, #Maps)]:Clone()
		for i = 30, 1, -1 do
			Status.Countdown.Value = "Next round starting in: "..i
			task.wait(1)
		end
		Status.Countdown.Value = "Choosing map.."
		task.wait(2)
		Status.Countdown.Value = "Map Choosed! "..RandomMap.Name
		task.wait(2)
		RandomMap.Parent = workspace
		for i, ServerPlayers in pairs(game.Players:GetPlayers()) do
			ServerPlayers.Character.HumanoidRootPart.CFrame = RandomMap.Spawn.CFrame
		end
		Time()
		RandomMap:Destroy()
		for i, ServerPlayers in pairs(game.Players:GetPlayers()) do
			ServerPlayers.Character.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame
		end
		MainFunction()
	--end
end

MainFunction()

First, you need to display the UI for choosing your role. Then whenever a role is clicked, send a :FireServer(role) request to the remote event. In the server, listen to the remote event, you will have the player who sent the request, and the role they want. You can perform the role change in the server

more about this:

Sorry if i didn’t mean it correctly, but that’s… not wha i mean, i don’t mean YOU choose your character, i mean the game chooses (more like a random parent/son chose)

1 Like

Oh well, sorry for the misunderstanding, thats way simpler now. You can just loop over all the participating players and assign them a the random role using math.random

for _, player in Players:GetPlayers()
   local Role = Roles[math.random(#Roles)]
   -- Assign it to the player
end

If your roles are using teams, then assign it by using player.Team = Role

i’m not asking for a full script, but how can i make chances, like baby is a bit more common and the parent is a bit… rare?

I’d go about it as follows:

for _, player in next, Players:GetPlayers()
    -- generate random number and assign team based on that
    local randomNum = Random.new():NextInteger(0, 100) -- random integer from 0 - 100
    
    if randomNum <= 40 then
        -- set team to baby
    else 
       -- set team to parent
    end
end

this way 40% of players would be a baby and 60% would be a parent.

1 Like

well, the reverse, but i get what do you mean now, i just need to do the other thing