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

PlayerAdded is not working suddenly this week?

Asked by 5 years ago
Edited 5 years ago

Whenever I try to team someone in the playeradded it doesn't team them, it is wierd cause it was working a week ago.

(Also if I try printing something it does work, it is simply just not teaming the player)

USM = "United States Army"
JMP = "Military Police"
VISITOR = "Visitors"

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    if player:IsInGroup(4490133) then
    print("yee")
    player.TeamColor = BrickColor.new("Fossil")
    elseif player:IsInGroup(4490133) then
    player.TeamColor = game.Teams[USM].TeamColor
    else
    player.TeamColor = game.Teams[VISITOR].TeamColor
    end
end)

game.Players.PlayerRejoining:connect(function(player)
    if player:IsInGroup(4490133) then
    player.TeamColor = game.Teams[JMP].TeamColor
    elseif player:IsInGroup(4490133) then
    player.TeamColor = game.Teams[USM].TeamColor
    else
    player.TeamColor = game.Teams[VISITOR].TeamColor
    end
end)
0
If you're doing this on the client, PlayerAdded does not fire for the client the LocalScript is running on. A LocalScript is typically the descendant of a Player instance, and the player needs to exist before its descendants (like the PlayerGui, and this is one of the places where LocalScripts run) can exist. User#19524 175 — 5y
0
However PlayerAdded *will* fire on the client for clients who join afterwards. User#19524 175 — 5y
0
This is being run in a server script, not local. nestriff 27 — 5y
0
PlayerRejoining is not usable in scripts, https://developer.roblox.com/api-reference/event/Players/PlayerRejoining Vulkarin 581 — 5y

Answer this question