For some reason my onTouch function doesnt work

local player = game.Players.LocalPlayer

local cardpack = game.Workspace.CardPackXD
cardpack.Touched:Connect(function(hit)
	
	if player:FindFirstChild("Humanoid") then
		print("a")
		
		cardpack:Destroy()
		
	end
	
end)

You need to check if the hit variable is a player.

if hit.Parent:FindFirstChild("Humanoid") then
		print("a")
		
		cardpack:Destroy()

Technically it does work, except not the way you expected.

cardpack.Touched:Connect(function(hit)

The Touched event takes one argument which will be sent to the function, in this case, hit, which is the part that touched the part and fired the event. However, your next line is:

if player:FindFirstChild("Humanoid") then

Now, player is not a parameter passed to the function, but instead you previously declared as the LocalPlayer. This would not work, as you would be always looking for a humanoid in your own player.

To solve that, we want the function to find any part that was touched, aka finding anyone, rather than just your own character. That’s the reason we declared the hit parameter:

local cardpack = game.Workspace.CardPackXD
cardpack.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildOfClass("Humanoid") then
        -- Hit is the object that touched the cardpack
        -- Additionally, use :FindFirstChildOfClass("Humanoid") to make sure it's a player
		print("a")
		cardpack:Destroy()
	end
end)

Additionally, this should be a Server script instead, because the destroyed cardpack won’t replicate to other clients since you ran it in your own client.

Heres the thing, i did it in local because I want the local player who touched it to be the ONLY one who see the cardpack be destroyed. in other way if a player takes the pack noone else can and that ruins the point of the pack and i cant think of any other way to make it only get destroyed for the player.and also theres the thing with me wanting to make it so it checks if the player has already destroyed the thing in the past (other server ect) and save it in a the save data service im doing.