Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I force a player to wear a certain clothing when he joins? (my script doesnt work)

Someone please help me I dont know why this script doesnt work

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local Player    = game.Players.LocalPlayer
local Character = Player.Character
local Shirt     = Character:FindFirstChild("Shirt") or Instance.new("Shirt", Character) -- if its in character then get shirt else make a new one
local Pants     = Character:FindFirstChild("Pants") or Instance.new("Pants", Character)
 
local shirtId   = "https://www.roblox.com/catalog/1303497675/Prison-Prison-Prison-Prison-Prison-Prison-Prison" -- put the shirt id here
local pantsId   = "https://www.roblox.com/catalog/1280655173/Prison-Prison-Prison-Prison-Prison-Prison-Prison" -- put the pants id here
 
Shirt.ShirtTemplate = "rbxassetid://"..shirtId -- set the shirt
Pants.PantsTempalte = "rbxassetid://"..pantsId -- set the pants
end)

Please help Ive also tried only putting the ID onstead of the full link but it still doesnt work!

1 comment

0

you misspelled "PantsTemplate"

2 answers

I see your problem. Your basically adding the whole roblox link onto the shirts template, instead of just the number. You should have also used a character added script. You can't use local player on a server script. Put this script in server script service. Here is your fixed script:

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local Player    = player
local Character = char
local Shirt     = Character:FindFirstChild("Shirt") or Instance.new("Shirt", Character) -- if its in character then get shirt else make a new one
local Pants     = Character:FindFirstChild("Pants") or Instance.new("Pants", Character)


Shirt.ShirtTemplate = "rbxassetid://1303497675"
Pants.PantsTemplate = "rbxassetid://1280655173"
end)
end)

In fact i used a local script and i also tried not adding the whole thing i guess the problem was the fact that the script wasnt character added but thanks! Edit: there is a problem, there is no such thing as a server script storage

2 comments

0

O sorry, i ment server script service.

0

yeah that doesnt work too...

This discussion is preserved as it was. New answers, comments, and votes are closed.