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

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

Asked by 4 years ago
Edited 4 years ago

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

0
You cannot use game.Players.LocalPlayer in a server script, instead use .PlayerAdded Cynical_Innovation 595 — 4y
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") ' Fullmando 4 — 4y
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 Amiaa16 3227 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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.

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") ' Fullmando 4 — 4y
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. PURGATORYAGENT_1 43 — 4y
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. Fullmando 4 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question