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

Why is plr.CharacterAdded:connect(function(char) Not working???

Asked by
Nik1080 24
7 years ago
Edited 7 years ago

This is a script I composed to change any character that joins the game's clothing:

plr.CharacterAdded:connect(function(char)
    player.Pants.PantsTemplate = 182807730
    player.Shirt.ShirtTemplate = 182807618
end)

Basically, when I try to run this, my character's clothing flashes grey (loading the texture I assume) then going to what my character is set to look like. (Not what the PantsTemplate / ShirtTemplate is set to in the script) What am I doing wrong

1
can you post the full script. User#5423 17 — 7y
0
Is this a script or a localscript? GoldenPhysics 474 — 7y
0
*It is a regular script, does it need to be a local script?* Nik1080 24 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

This isn't anywhere near a full script.

How do you get plr? Where is it defined? It isn't. Along with that, the Pants and Shirt are in the character, not the player, which again you don't define.

To get the player I suggest the PlayerAdded function.

-- Regular Script in ServerScriptService
--// Services
local Players = game:GetService("Players")

--\\ Code
Players.PlayerAdded:Connect(function(plr)

end)

Cool! Now we have the player; let's get the character. We can get the character with the CharacterAdded event.

-- Regular Script in ServerScriptService
--// Services
local Players = game:GetService("Players")

--\\ Code
Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)

    end)
end)

Now we should be able to add your code:

-- Regular Script in ServerScriptService
--// Services
local Players = game:GetService("Players")

--\\ Code
Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:WaitForChild("Pants").PantsTemplate = 182807731
        char:WaitForChild("Shirt").ShirtTemplate = 182807619
    end)
end)
0
It's not working Nik1080 24 — 7y
0
Probably has to do with the PantsTemplate and stuff. Might need to be a string. OldPalHappy 1477 — 7y
Ad

Answer this question