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)
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)