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

How do I search for the character’s clothes, within a server script?

I want to change the clothes ID of players who enter my game, they can choose the clothes they want, but I’m not getting.

Yes, my game is published !

-- Character Customization --
local players = game:GetService("Players")
local player = game.Players.LocalPlayer

local function STARTER(plr)
	

local character = plr.Character or plr.CharacterAdded:wait()
local Pants = character:WaitForChild("Pants")
local Shirt = character:WaitForChild("Shirt")

--Shirt Inicialization
local ListShirt = {"rbxassetid://1402902415"}
Shirt.ShirtTemplate = ListShirt[1]

--Pants Inicialization
local ListPants = {"rbxassetid://1402900791"}
Pants.PantsTemplate = ListPants[1]

end

players.PlayerAdded:Connect(STARTER)

TS: If i put 'print(“something”) ’ behind local shirt, it’s work, but if is after, it’s don’t work, so i think local shirt is wrong

3 comments

0

You cannot use game.Players.LocalPlayer in a server script, instead use .PlayerAdded

0

I think there is no way to send an image here, but it gave an 'Infinite yield possible in the' Workspace.Fullmando: WaitForChild ("Pants") '

0

First of all not all players wear shirts/pants. Second of all the shirt/pants don't have to be named "Shirt" or "Pants", hence why your WaitForChild never finds either

2 answers

Server scripts are scripts run on the server. Local scripts are scripts that are run on the clients. The people in your game.

Only local scripts can use LocalPlayer

You will need to bind this to a PlayerAdded event.

game.Players.PlayerAdded:Connect(function(Player)
    print(Player.Name)
end)

This code above will print the name of the player who has just joined the game.

3 comments

0

I think there is no way to send an image here, but it gave an 'Infinite yield possible in the' Workspace.Fullmando: WaitForChild ("Pants") '

0

WaitForChild will wait as the name suggests until the thing that it is looking for has been found. Are you suring the item of clothings name is Pants? It is case sensitive.

0

Yes, I want my character's pants, in this case is 'Fullmando'. I want change the ID Template of Pants. But it doesn't found so.

Guys i discover the error, in fact I had to create a new instance.

local PantsServer = Instance.new("Pants")
PantsServer.Name = "Pants"
PantsServer.Parent = character
local ShirtServer = Instance.new("Shirt")
ShirtServer.Name = "Shirt"
ShirtServer.Parent = character

local Shirt = character:WaitForChild("Shirt")
local Pants = character:WaitForChild("Pants")

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