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:

local TC = Instance.new("RemoteEvent")
TC.Name = "TeamChanger"
TC.Parent = game.ReplicatedStorage
local teams = game.Teams

TC.OnServerEvent:Connect(function(Player, TeamName)
    Player.Team = game.Teams[TeamName]
    Player:LoadCharacter()
    char = Player.Character


    if Player.Team == "Counter Terrorists" then
        if char:FindFirstChild("Shirt") then
            char.Shirt:Destroy()
        end

        if char:FindFirstChild("Pants") then
            char.Pants:Destroy()
        end

        local shirt = teams["Counter Terrorists"].Shirt:Clone()
        shirt.Parent = char
        local pants = teams["Counter Terrorists"].Pants:Clone()
        pants.Parent = char
    else
        if char:FindFirstChild("Shirt") then
            char.Shirt:Destroy()
        end

        if char:FindFirstChild("Pants") then
            char.Pants:Destroy()
        end

        local shirt = teams["Terrorists"].Shirt:Clone()
        shirt.Parent = char
        local pants = teams["Terrorists"].Pants:Clone()
        pants.Parent = char

    end
end)
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...

local TC = Instance.new("RemoteEvent")
TC.Name = "TeamChanger"
TC.Parent = game.ReplicatedStorage
local teams = game.Teams

TC.OnServerEvent:Connect(function(Player, TeamName)
    Player.Team = game.Teams[TeamName]
    Player:LoadCharacter()
    char = Player.Character


    if Player.Team.Name == "Counter Terrorists" then
        if char:FindFirstChild("Shirt") then
            char.Shirt:Destroy()
        end

        if char:FindFirstChild("Pants") then
            char.Pants:Destroy()
        end

        local shirt = teams["Counter Terrorists"].Shirt:Clone()
        shirt.Parent = char
        local pants = teams["Counter Terrorists"].Pants:Clone()
        pants.Parent = char
    else
        if char:FindFirstChild("Shirt") then
            char.Shirt:Destroy()
        end

        if char:FindFirstChild("Pants") then
            char.Pants:Destroy()
        end

        local shirt = teams["Terrorists"].Shirt:Clone()
        shirt.Parent = char
        local pants = teams["Terrorists"].Pants:Clone()
        pants.Parent = char

    end
end)
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