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

Why does my team change script not change clothes?

Asked by 4 years ago
Edited 4 years ago

I have a simple team change script that also changes the clothes but always changes the clothes to the terrorist side clothes, any help is appreciated.

Video: https://streamable.com/b3al2c

Explorer: https://imgur.com/a/Ltseznk

Code:

01local TC = Instance.new("RemoteEvent")
02TC.Name = "TeamChanger"
03TC.Parent = game.ReplicatedStorage
04local teams = game.Teams
05 
06TC.OnServerEvent:Connect(function(Player, TeamName)
07    Player.Team = game.Teams[TeamName]
08    Player:LoadCharacter()
09    char = Player.Character
10 
11 
12    if Player.Team == "Counter Terrorists" then
13        if char:FindFirstChild("Shirt") then
14            char.Shirt:Destroy()
15        end
View all 40 lines...
0
Line 12 should either check if the player's team name is equal to "Counter Terrorists" or if the player's team is equal to the actual team object (ie game.Teams["Counter Terrorists"]. Right now, you're asking if the team object is equal to a string. Gey4Jesus69 2705 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

As explained in my comment...

01local TC = Instance.new("RemoteEvent")
02TC.Name = "TeamChanger"
03TC.Parent = game.ReplicatedStorage
04local teams = game.Teams
05 
06TC.OnServerEvent:Connect(function(Player, TeamName)
07    Player.Team = game.Teams[TeamName]
08    Player:LoadCharacter()
09    char = Player.Character
10 
11 
12    if Player.Team.Name == "Counter Terrorists" then
13        if char:FindFirstChild("Shirt") then
14            char.Shirt:Destroy()
15        end
View all 40 lines...
1
Thanks a lot! i think you just saved me from 5 years of searching stuff on the internet! EiOooAxea 70 — 4y
0
You're welcome. Upvote if it helped. Gey4Jesus69 2705 — 4y
Ad

Answer this question