I want to make it so whenever the player grabs the tool, the player's clothes change, however it doesnt seem to work

the script is:

local tool = script.Parent

local player = script.Parent.Parent

if player:findFirstChild(“tool”) then

if player:FindFirstChild(“Shirt”) then

player.Shirt.ShirtTemplate = 1217784679



Okay, So first of all you trying to locate “Shirt” in a player instance which doesn’t exist, it’s on the player’s character. Also, you shouldn’t use if player:FindFirstChild("tool") then because there is a better way.
The question is this in a local script or a server sided script so that I can help you

1 Like

Its a normal script. Does it have to be a local script?

No it does not have to be a local script it is better to have it as a sever script, because all players can see the changes. Let me make a script for you to understand and learn from. give me a moment please

1 Like
local Tool = script.Parent ---Locate your tool instance here

	local AllPlayers = game:GetService("Players") --- Locate all players in game so we can locate the player holding the tool
	local CurrentPlayer = AllPlayers:GetPlayerFromCharacter(Tool.Parent)
	if not CurrentPlayer then----Repeat the line above to make sure we get the player
	else--- if the player is found this line works
		local Character = CurrentPlayer.Character or CurrentPlayer.CharacterAdded:Wait() --- locate the player, and if not found wait until it is found
		if Character then -- Check if theres a character
			local Shirt = Character:FindFirstChildWhichIsA("Shirt")-- locate shirt on player
			local Pants = Character:FindFirstChildWhichIsA("Pants")-- locate pants on player
			Shirt.ShirtTemplate = ""---here you would fill in what id you want
			Pants.PantsTemplate = ""---here you would fill in what id you want

Tell me if this works if not give me the errors, this goes in a server script in the tool

1 Like

Try this:

local Tool = script.Parent

     local Char = Tool.Parent

     local Shirt = Char:FindFirstChildWhichIsA("Shirt")

     Shirt.ShirtTemplate = "1234" -- Put ID here

     -- if you want the pants to do this. Otherwise delete this code

     local Pants = Char:FindFirstChildWhichIsA("Pants")

     Pants.PantsTemplate = "1234" -- Put ID here


I forgot the Equipped:Connect in the old version try this one out

local Tool = script.Parent

	local Character = script.Parent
	local Shirt = Character:FindFirstChildOfClass("Shirt")
	local Pants = Character:FindFirstChildOfClass("Pants")
	if Shirt then
		Shirt.ShirtTemplate = "rbxassetid://0" --Change 0.
	if Pants then
		Pants.PantsTemplate = "rbxassetid://0" --Change 0.

Why all the unecessary code? Also FindFirstChildOfClass() is more performant than FindFirstChildWhichIsA(), since the former looks for a child of a specific class whereas the latter looks for a child which inherits from the specified class.