Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change a hat's handle transparency?

Asked by
Lacin1a 12
5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
Thank You So Much! Lacin1a 12 — 5y
Ad
Log in to vote
0
Answered by
Zypsoh 25
5 years ago
Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(Player)
    player.Character.SleepingMaskHat.Handle.Transparency = 1
    end)
0
Try this one if doesn't work im sry xD Zypsoh 25 — 5y

Answer this question