so i am trying to remove the shirt of an player (if he wears one) and the remove it but if i ask if the player has a shirt and he does not the if statement still runs
if char.Shirt then char.Shirt:remove() end
If you are asking the player if they want to remove their shirt, but they do not have it in the first place, you need to use :FindFirstChild
, which returns nil if the shirt does not exist, and references the shirt itself it exists.
Your original attempt does not work if the player does not have shirt because it is attempting to find something that does not exist in the if statement itself (not a valid member of).
local shirt = char:FindFirstChild("Shirt") --if shirt exists, destroy it. if shirt then --Use Destroy since :remove is deprecated. shirt:Destroy() end
do not use :remove()
use :Destroy()
cough it's desperated
game.Players.PlayerAdded:Connect(function(player)--the player is added local char = player.Character --the character if char.Shirt then char.Shirt:Destroy() end end)