#Connecting a function to when a player joins the game, What is the thing called
1 messages · Page 1 of 1 (latest)
Players.PlayerAdded:Connect(function(player)
end)
Players = players:GetService("Players")
Players.PlayerAdded:connect(function(player)
whatever hjere
end) ```
W
Question lad
Why won't their shirt and pants change?
local player = game:GetService("Players")
local LPlayer = player.LocalPlayer
local Team = LPlayer.Team
local Rank = LPlayer:GetRankInGroup(1)
local Staff_Team_Ranks = {"24", "22", "22"}
local Supervision_Team_Ranks = {"", "", ""}
local Corporate_Team_Ranks = {"", "", ""}
function OnJoined(player)
if Rank == Staff_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Staff")
LPlayer:FindFirstChildOfClass("Shirt").ShirtTemplate = "rbxassetid://80018832805363"
LPlayer:FindFirstChildOfClass("Pants").PantsTemplate = "rbxassetid://95282531461583"
end
if Rank == Supervision_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Supervision Team")
end
if Rank == Corporate_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Corporate Team")
end
end
player.PlayerAdded:Connect(OnJoined)```
ok first
the function
why do you define the function then call it when they join
you can do it all in one block
Wait
** You are now Level 5! **
and is it in a local script
Yes
where
workspace rn
put it in starter player scripts
player.PlayerAdded:Connect(function(OnJoined) Would that work instead?
no
ill give
player.PlayerAdded:Connect(function(player(
if Rank == Staff_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Staff")
LPlayer:FindFirstChildOfClass("Shirt").ShirtTemplate = "rbxassetid://80018832805363"
LPlayer:FindFirstChildOfClass("Pants").PantsTemplate = "rbxassetid://95282531461583"
end
if Rank == Supervision_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Supervision Team")
end
if Rank == Corporate_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Corporate Team")
end
end
@static pumice
Thank you"
Outfit didn't change
any errors?
nope
Oh shit
I forgot to put it in there
I believe
Hold up
Teaming part is working
It's just the clothing now.
Noerrors at all
send new script
It's the exact same as before
how
** You are now Level 2! **
ok
local player = game:GetService("Players")
local LPlayer = player.LocalPlayer
local Team = LPlayer.Team
local Rank = LPlayer:GetRankInGroup(35153508)
local Staff_Team_Ranks = {"255", "224", ""}
local Supervision_Team_Ranks = {"", "", ""}
local Corporate_Team_Ranks = {"", "", ""}
player.PlayerAdded:Connect(function(player)
if Rank == Staff_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Staff")
LPlayer:FindFirstChildOfClass("Shirt").ShirtTemplate = "rbxassetid://80018832805363"
LPlayer:FindFirstChildOfClass("Pants").PantsTemplate = "rbxassetid://95282531461583"
end
if Rank == Supervision_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Supervision Team")
end
if Rank == Corporate_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Corporate Team")
end
end)
That's the Script.
FYI: It didn't work
Ok so
you have rank
which is a integer
and comparing it to values in an array like staff_team_ranks
which contains them is a string
so it wont work
yea
One sec
for _, v in pairs(Staff_Team_Ranks .. Supervision_Team_Ranks .. Corporate_Team_Ranks) do```
Like that?
player.PlayerAdded:Connect(function(player)
for _, v in pairs(Staff_Team_Ranks) do
if Rank == v then
LPlayer.Team = game.Teams:FindFirstChild("Staff")
LPlayer:FindFirstChildOfClass("Shirt").ShirtTemplate = "rbxassetid://80018832805363"
LPlayer:FindFirstChildOfClass("Pants").PantsTemplate = "rbxassetid://95282531461583"
end
if Rank == Supervision_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Supervision Team")
end
if Rank == Corporate_Team_Ranks then
LPlayer.Team = game.Teams:FindFirstChild("Corporate Team")
end
end
end)
Is that correct?
yea just define the players service and stuff
and it should work
and the id is too long i think
you might just need the id not the rbxassetid://
@static pumice
Didn't work
put this into serverscriptservice, also remove all shirts and pants (if any) and add new ones with whatever you want, because if player doesnt have shirt or pants an error will occur
if you change something in a localscript, unless thats replicated it wont show up for others
heres a fixed script btw
local function removeClothing(character)
for _, v in character:GetChildren() do
if v:IsA("Clothing") then v:Destroy() end
end
end
game:GetService("Players").PlayerAdded:Connect(function(player)
local rank = player:GetRankInGroup(35153508)
if rank == some_rank then
player.Team = some_team
elseif rank == some_other_rank then
player.Team = some_other_team
end
player.CharacterAppearanceLoaded:Connect(function(character)
removeClothing(character)
-- now apply custom clothing, probably by storing it in ServerStorage then cloning and parenting to character
end)
end)
obviously its not fully done but you get the idea
Local or normal script
.
you cant change teams in local scripts
neither shirts templates
(properly)
because that will only show up for you
and you probably want everyone see your new shirt
in your another topic people already answered you i think
They did but made no sense so
Then someone was being a rude bitch sooooo I gsve up
they did in fact