Shirt Error, Help

Hello,
Im a beginner scripter, and i would like to know why it doesnt work?

local shirtid = script:FindFirstChild("Shirt")
local pantsid = script:FindFirstChild("Pants")


script.Parent.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	
	plr.leaderstats.Money.Value += -50
	plr.Shirt.ShirtTemplate = shirtid
	plr.Pants.PantsTemplate = pantsid
end)

1 Like

Do you have any errors in output, please would you send an image of the hierarchy around the script

It says “Shirt not found on plr”

Would you please send a screenshot, of the error and what exactly is ShirtID and pantsID, is that a string value?

You can literally use plr.leaderstats.Money.Value -= 50. If this was intentionally made to make programmers mad, then it sure is making me mad.

1 Like

You need to use plr.Character.
Also, you have to use:

shirtid.ShirtTemplate
pantsid.PantsTemplate

shirtid is not a valid member of Model “Workspace.boy_gamer20044”
It gives me this error

i said im new to scripting, so yee

plr.Character.Shirt.ShirtTemplate = shirtid.ShirtTemplate

Same with pants.

True but there’s no way you’d know how to increment values but not know how to deincrement values.

But at least now you know.

local shirtid = script:FindFirstChild("Shirt")
local pantsid = script:FindFirstChild("Pants")


script.Parent.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	
	plr.leaderstats.Money.Value -= 50
	plr.Character.Shirt.ShirtTemplate = shirtid.ShirtTemplate
	plr.Character.Pants.PantsTemplate = pantsid.PantsTemplate
end)

Also, I noticed you put += -50, that could work. But if you want to subtract, why not just use -=?
[If you didnt know, hope you’ll use this from now on this way, since it’s more efficient]

Also, it’s possible that the player doesnt have a shirt/pants on himself. Thus, you’ll need to check for that, and when it happens, create a shirt and/or a pants for him with the ID’s you stored above.

It still doesnt work, very wierd

Could you please show us screenshots?

robloxapp-20220504-1731289.wmv (1.3 MB)
Here is a clip

This clip doesnt really help much, I understand the issue,

But I need to see relevant screenshots from studio[ show us where that part is located and the script + those clothes location aswell], that might help us.


image

Is this enough to know where the problem is?

local ShirtID = 244124412 -- Enter it here
local PantsID = 345325322 -- Enter it here

local Price = 50

[path.to.proximityPrompt].Triggered:Connect(function(player)

   --// Data
   local Money = player.leaderstats.Money

   if Money.Value >= 50 then
      Money.Value -= Price
   else
      warn(player.Name.." does not have enough money! Need: "..(Price - Money.Value))
   end

   --// Character
   local Character = player.Character or player.CharacterAdded:Wait()
   Character:FindFirstChildWhichIsA("Shirt").ShirtTemplate = "rbxassetid://"..ShirtID
   Character:FindFirstChildWhichIsA("Pants").PantsTemplate = "rbxassetid://"..PantsID

end)

This should work also make sure to commit your scripts since the error doesn’t add up to the code.

Could show me the script and the explorer of the character.