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

Why does this CharacterAppearance only works in Solo mode?

Asked by
Jurdy 0
10 years ago
game.Players.PlayerAdded:connect(function(p)
    wait(1)
for i, v in ipairs(game.Players:GetChildren())do
    v.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=179631998"
    v.Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=179650451"
    end

end)

-- Its a script in Workspace and it seems to work in solo mode, but doesn't in- game. Please help!
0
Please help, it only works in solo :( Jurdy 0 — 10y
0
Change "wait(1)" to "repeat wait() until p.Character Discern 1007 — 10y

1 answer

Log in to vote
0
Answered by
samfun123 235 Moderation Voter
10 years ago

I've fiddled with the code a bit and made some improvements.

For whatever reason Start Server doesn't give the players a pants or shirt object so I added some code to fix that.

Version 1: This will give the player the shirt and pants when they join the game.

game.Players.PlayerAdded:connect(function(p)
    repeat wait() until p.Character -- Wait for a character
    local char = p.Character
    if not char:FindFirstChild("Shirt") then -- If they don't have a shirt object give them one
        Instance.new("Shirt",char).Name = "Shirt"
    end
    if not char:FindFirstChild("Pants") then -- If they don't have a pants object give them one
        Instance.new("Pants",char).Name = "Pants"
    end
    char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=179631998"
    char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=179650451"
end)

Version 2: This will give the player the shirt and pants every time they respawn and when they join the game

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(char)
        repeat wait() until p.Character -- Wait for a character
        local char = p.Character
        if not char:FindFirstChild("Shirt") then -- If they don't have a shirt object give them one
            Instance.new("Shirt",char).Name = "Shirt"
        end
        if not char:FindFirstChild("Pants") then -- If they don't have a pants object give them one
            Instance.new("Pants",char).Name = "Pants"
        end
        char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=179631998"
        char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=179650451"
    end)
end)
0
still doesn't work, only works in solo Jurdy 0 — 10y
0
I think I fixed it samfun123 235 — 10y
Ad

Answer this question