Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change a hat's handle transparency?

So I am trying to make a show and hide feature for a hat. I'm doing by going to the handle and changing its transparency.

Here Is My Script For Cloning The Hat From ServerStorage (Script):

game.Players.PlayerAdded:Connect(function(player)
	wait()
	local AddMask = game.ServerStorage.SleepingMaskHat:Clone()
	AddMask.Parent = player.Character
end)

Here Is My Script For Changing(LocalScript):

	
script.Parent.MouseButton1Click:Connect(function(player)
	player.Character.SleepingMaskHat.Handle.Transparency = 1
	end)

Error Message: attempt to index local 'player' (a nil value)

2 answers

✓ Accepted answer

TextButton events don't pass a player as a parameter, but PlayerAdded and PlayerRemoving do. And that means that you should remove the player parameter from the MouseButton1Click event

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    player.Character.SleepingMaskHat.Handle.Transparency = 1
end)

1 comment

0

Thank You So Much!

Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(Player)
    player.Character.SleepingMaskHat.Handle.Transparency = 1
    end)

1 comment

0

Try this one if doesn't work im sry xD

This discussion is preserved as it was. New answers, comments, and votes are closed.