How can I get the player’s current t-shirt (in a server script)? Also, how can I check if the player owns the t-shirt he is wearing? Thanks in advance.
1 Like
Get the player.Character and do :FindFirstChild(“Shirt”). Then you can do the .ShirtID.
1 Like
You mean like this?
player.Character:FindFirstChild("T-Shirt").ShirtID
You can find the character from a LocalScript then get the shirt/t-shirt. To check if the player owns the shirt, you can use MarketplaceService and use the PlayerOwnsAsset with the Id of the shirt.
local MarketplaceService = game:GetService(“MarketplaceService”)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local shirtId
local tShirtId
local function playerOwnsAsset(id)
if MarketplaceService:PlayerOwnsAsset(id) then
return true
else
return false
end
end)
for _, obj in pairs(Character:GetChildren()) do
if obj:IsA(“Shirt”) then
shirtId = obj.ShirtTemplate
elseif obj:IsA(“ShirtTemplate”) then
tShirtId = obj.Graphic
end
end
print(“Shirt:”, playerOwnsAsset(shirtId))
print(“T-Shirt”, playerOwnsAsset(tShirtId))
1 Like
Just in addition to this, please pcall the PlayerOwnsAsset or else it may error at one point and break your game.
2 Likes