Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Role chooser not responding to when the player joins. How do I fix this problem?

Asked by 4 years ago

I'm making a murder mystery type game.There's a virus, the doctor, and finally the other civilians, but my script keeps saying in the output, "no players." Even though I'm fully inside of the game ready to play. Here's the script:

local killWeapon = game.ServerStorage.Claws

local Players = game.Players

local player = Players:GetChildren()

wait(5)

if #player == 0 then
    print("No players.")
    return
end

if#player >= 1 then
    local pickedPl = player[math.random(1, #player)]
pickedPl.StarterGui.Role.Frame.Visible = true
pickedPl.StarterGui.Role.Frame.Roletell.Text = "Murderer"
pickedPl.StarterGui.Role.Frame.Roletell.TextColor3 = Color3.new(255, 0, 0)
killWeapon.Parent = pickedPl.Backpack

local pickedP2 = player[math.random(1, #player)]

if player ~= pickedPl then
    if player == pickedP2 then
        pickedP2.StarterGui.Role.Frame.Visible = true
        pickedP2.StarterGui.Role.Frame.Roletell.Text = "Scientist"
        pickedP2.StarterGui.Role.Frame.Roletell.TextColor3 = Color3.new(0, 0, 255)
    end
end

if player ~= pickedPl or pickedP2 then
    pickedP2.StarterGui.Role.Frame.Visible = true
    pickedP2.StarterGui.Role.Frame.Roletell.Text = "Survivor"
    pickedP2.StarterGui.Role.Frame.Roletell.TextColor3 = Color3.new(0, 255, 0)
end
end




0
Use Players:GetPlayers() Ziffixture 6913 — 4y
0
Didn't help. Output still responded with No players. Prxticles 13 — 4y

Answer this question