Can it be done without local scripts?

so I made role randomizer to my game, but it only appears for one player at once, and after animation for one player is finished, then it appears for another player. is it possible to make it appear for every player at same time without local scripts?


	local function roleSelecting(player)
		local role = player.PlayerGui:WaitForChild("MainMenu").RoleSelect
		role.Visible = true
		for i = 1, 0, -0.02 do -- screen fades to black
			role.BackgroundTransparency = i

		if player.Objectives.Role.Value == "FirstRole" then -- checks for roles
			game:GetService("TweenService"):Create(role.FirstRole,, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {TextTransparency = 0}):Play()
			game:GetService("TweenService"):Create(role.FirstRole,, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {TextTransparency = 1}):Play()
		elseif player.Objectives.Role.Value == "SecondRole" then
			game:GetService("TweenService"):Create(role.SecondRole,, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {TextTransparency = 0}):Play()
			game:GetService("TweenService"):Create(role.SecondRole,, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {TextTransparency = 1}):Play()
	for i, player in pairs(game.Players:GetPlayers()) do

pretty sure its maybe not possible but if you make a regular script, make disabled localscripts that turn on the gui, then clone and enable it to the next player, it could work

1 Like

I did it with remote events, but thanks for help

I think you can use the ‘spawn’ thingy to spawn the function as a new thread so it doesn’t yield. Or use a function like Players.PlayerAdded / Event.Fired:Connect.

The way it is currently working: Run code for player 1, wait for player 1 code to finish and run player 2 code.

1 Like

I already made it with local scripts, and I tried spawn function(didn’t work well)

If you have the script in starter gui, it’ll replicate to each player so that each player get’s their own role randomiser

Role is choosen in server script, and then remote event is fired to player to show the gui

could send the role in a RemoteEvent (server side)

RoleRemoteEvent:FireClient(playerX, roleY)

then the client side should do this

RoleRemoteEvent.ClientEvent:Connect(function (roleY)
    roleSelecting(LocalPlayer, roleY)