Attempt to connect failed: Passed value is not a function

so I’m trying to make it load a shirt from it’s catalog id, if I enter in manually it will load the asset id, but if a script does it it just stays the numbers and will not load

wait(5)

local Player = script.Parent.Parent.Parent
print(Player.Name)

local PrimaryColor = script.Parent.PrimaryColor
local SecondaryColor = script.Parent.SecondaryColor

local character
for i, v3  in pairs(workspace:GetChildren()) do
	if v3.Name == Player.Name then
		character = v3
	end
end
local shirt = character.Shirt

local Clothingids = game.ReplicatedStorage.GradientClothing.Shirt:GetChildren()

function UpdateCLothing()
	for i, v in pairs(Clothingids) do
		if v.Name ==  PrimaryColor.Value then
			local scs = v:GetChildren()
			for i, v2 in pairs(scs) do

				if tostring(v2) == tostring(SecondaryColor.Value) then
					shirt.ShirtTemplate = tonumber(v2.Value)
				end
			end
		end
	end
end

PrimaryColor.Changed:Connect(UpdateCLothing())

SecondaryColor.Changed:Connect(UpdateCLothing())

basically, how can I make a catalog id into and asset id with scripts

You don’t put the 2 parenthesis when connecting functions. Just:

SecondaryColor.Changed:Connect(UpdateCLothing)
1 Like

ok, but it still isn’t loading the shirt
It just shows the id
but if i put in the id manually it shows the shirt

Yeah, try:

shirt.ShirtTemplate = "rbxassetid://" .. v2.Value

When setting a shirt or pants ID, you need this format:
rbxassetid://[Number] (String)

1 Like

ok, it’s still not working, I used the shirt id and assigned that because I thought since it worked when i did it manually it would work with the code

I think that Image rbxassetid:// is part of the solution, but i need to get the shirt id into the asset id first

For asset id’s to work they have to be “pre-loaded” (I am not quite sure the real name). To see this in action paste a catalogue id into a shirt inside of studio and watch the number magically change (not into “rbxassetid://”…num).

1 Like

I’ve actually changed a persons shirt before just using rbxassetid. So I know it works.

1 Like

You should look for other similar posts before making your own here are a few that may help:

Getting decal texture id from site? - Development Discussion - DevForum | Roblox
How to load Pants/Shirts using scripts - Help and Feedback / Scripting Support - DevForum | Roblox

1 Like

I have done that, and if i do it manually it works and and the shirt is on my character but when a script does it, it stays whatever input you set it to…

Have a look at my solution for this similar question: Code issues - The player does not equip clothes - #7 by Avallachi

1 Like

I just found it here, How to change a ShirtTemplate after a server has started? - #4 by Intended_Pun

it’s pretty similar to yours, thankyou :smiley: