I am not using a model it is a player they can pick shirts and i have added GUI’s but when they click on them it doesn’t change their Shirt it stays the same
So i did it and its worked so the problem is that “Shirt” did’nt load you used FindFirstChild but Shirt is not here use
char:WaitForChild(“Shirt”).ShirtTemplate = “http://www.roblox.com/asset/?id=5008248562”
Ok so the problem is because my Avatar is not wearing a shirt and i wore a shirt and it worked but is there a way to Force them to wear a shirt once clicked?
@Beez_up
Yeah you can check if there is a shirt by using an if statement else add a shirt by using Instance.new(“Shirt”)
ok thank you could you type the code for me please?
@Beez_up
game.ReplicatedStorage.Events.ShirtEvent1.OnServerEvent:Connect(function(plr)
local char = plr.Character
if char:FindFirstChild("Shirt") then else
local s = Instance.new("Shirt")
s.Parent = char
end
char:FindFirstChild("Shirt").ShirtTemplate = "rbxassetid://5008248562"
end)
Please do not ask that on this category. This category is not a do-my-work category. You should be using the advice that developers are giving you and turning this into fix attempts first and asking for help based on what you’ve attempted and debugged. Consult existing resources, such as the Developer Hub, for API help.
I wasnt really trying to make them do my work ive been on this problem for hours so i said that out of frustration and im sorry
Don’t throw away what FindFirstChild
returns.
local char = plr.Character
if not char then return end
local shirt = char:FindFirstChildWhichIsA("Shirt")
if not shirt then
shirt = Instance.new("Shirt")
shirt.Parent = char
end
shirt.ShirtTemplate = "rbxassetid://5008248562"
and now I’ve looked at the word “shirt” too much, and it doesn’t look like a real word anymore
Can you show us the script that fires the event?(Code of it.)
It still does not work what I am trying to do is force people to wear a shirt because some people like to not wear any clothes and change their skin tone, but I want people to be forced to wear clothes once they click on a shirt in-game @ClockworkSquirrel
script.Parent.MouseButton1Click:connect(function()
game.ReplicatedStorage.Events.ShirtEvent1:FireServer()`
end)
Have you tried using the Game Settings window? This will allow you to override default clothing for characters.
Hmm, i think i noticed something, try using this:
game.ReplicatedStorage:WaitForChild("Events").ShirtEvent1:FireServer()
Also from what i remember, connect is deprecated, use Connect instead.
no i have not, but remember its a customization menu if they are forced to wear a shirt then they cant pick any other clothes
local char = plr.Character or plr.CharacterAdded:Wait()
local shirt = char:WaitForChild(“Shirt”,4.2) – Important
if shirt then print(“Player owns a shirt”) else print(“Player does not own a shirt”) end
I will not give you the code but this is how you know if the player wears a shirt
I am sorrry i forgot to tell you that :WaitForChild can have a time out so the code that i’ve gave you wouldnt work because it will wait until a shirt is there.
They’ll spawn wearing the default clothing you’ve set, and then they can change it in your customisation menu. Just use the code others have contributed above.
Okay thank you I will try that, I will get back to you if it doesn’t work!
Here is the full code
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local shirt = char:WaitForChild("Shirt",1)
if shirt then
shirt.ShirtTemplate = "" --- you're id
else
local newshirt = Instance.new("Shirt")
newshirt.Parent = char
newshirt.ShirtTemplate = "" --- id
end
If it works please click the button solved above
Ok i made them wear plain white clothing thank you for the idea