game.Players.PlayerAdded:Connect(function(p)
local function Clicked()
if p:GetRankInGroup(9536284) >= 3 then
p.TeamColor = BrickColor.new("Sea green")
p:LoadCharacter()
end
end
event.OnServerEvent:Connect(Clicked)
end)
When I click the team changer in StarterUI, everyone above that rank gets their team changed. How can I make it one person only?
When I click it, everyone in the server that is above that rank stated will get their team changed, I only want the person who clicked it to be on that team.
You should connect the function outside the PlayerAdded event. You’re connecting it everytime a new Player is added, Meaning all Players are gonna be affected no matter who fires it.
RemoteEvent.OnServerEvent:Connect(function(Player)
-- Function runs here
end)
Don’t wrap that in a PlayerAdded event, instead make a function that has a player parameter (onserverevent first parameter), then check the player’s rank value
local folder = game:GetService("ReplicatedStorage").TeamChangeEvents
local event = folder.CA
local sofcom = folder.CANSOFCOM
local cfmp = folder.CFMP
local civ = folder.CIV
local core = folder.CORE
local hq = folder.HQ
local cadtc = folder.CFDTC
event.OnServerEvent:Connect(function(p)
local function Clicked()
if p:GetRankInGroup(9536284) >= 3 then
p.TeamColor = BrickColor.new("Sea green")
p:LoadCharacter()
event.OnServerEvent:Connect(Clicked)
end
end
end)```
local p = game.Players.LocalPlayer
local function Clicked()
if p:GetRankInGroup(9536284) >= 3 then
p.TeamColor = BrickColor.new("Sea green")
p:LoadCharacter()
event.OnServerEvent:Connect(Clicked)
end
end
local p = game.Players.LocalPlayer
local function Clicked()
if p:GetRankInGroup(9536284) >= 3 then
p.TeamColor = BrickColor.new("Sea green")
p:LoadCharacter()
end
end
event.OnServerEvent:Connect(Clicked)
local function Clicked(player, teamColor)
if p:GetRankInGroup(9536284) >= 3 then
p.TeamColor = teamColor
p:LoadCharacter()
end
end
event.OnServerEvent:Connect(Clicked)