Hello everyone, I’m experimenting with randomly selecting roles for players. Three roles are in ReplicationStorage and one of the random ones appears in the player. But there is a problem: if the player is given a second role, then the elseif block is not executed; Instead, a warning is written in the console: Infinite yield possible on ‘Workspace.SCILEME:WaitForChild(“FunnyMan”)’. And if the first role is chosen, then everything is in order. I will be very grateful for your help. Here are the scripts:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
local RandomRoles = game.ReplicatedStorage:WaitForChild("Roles"):GetChildren()
local Randomizer = RandomRoles[math.random(1, #RandomRoles)]
Randomizer.Parent = player.Character
end)
This is server script it randomly selects a role and places it in the player
if game.Players.LocalPlayer.Character:WaitForChild("FunnyMan") then
print("Funny")
elseif game.Players.LocalPlayer.Character:WaitForChild("NeutralMan") then
print("Neutral")
elseif game.Players.LocalPlayer.Character:WaitForChild("BoredMan") then
print("Bored")
end
This is a local script that checks what role the player currently has (An error occurs here)