Need help with script meant to change the transparency of a part in a tool on touch

greetings all, i have this script in which a transparent part in my tool is meant to become visible on touch of another part

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	local tool = player.Backpack.IdentificationCard
	local toolequipped = player.IdentificationCard

	tool.REDCARD.Transparency = 0
	toolequipped.REDCARD.Transparency = 0
	
end)

unfortunately this doesn’t work, i also want the script to work when the tool is unequipped, so when equipped the part is visible

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if not player then return end
	local tool = player.Backpack:FindFirstChild("IdentificationCard") or player.Character:FindFirstChild("IdentificationCard")
    if not tool then return end
	tool.REDCARD.Transparency = 0
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.