script.Parent.MouseButton1Click:connect (function ()
playername = script.Parent.Parent.Parent.Parent.Parent.Parent.Name
player = Workspace:FindFirstChild(playername)
if player.player ~= nil then
local player.player = script.Parent
local humanoid = Player.Player:WaitForChild("Humanoid")
-- Create the Accessory.
local clockworksShades = Instance.new("Accessory")
clockworksShades.Name = "ClockworksShades"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1,1.6,1)
handle.Parent = clockworksShades
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "FaceFrontAttachment"
faceFrontAttachment.Position = Vector3.new(0,-0.24,-0.45)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1,1.3,1)
mesh.MeshId = "rbxassetid://1577360"
mesh.TextureId = "rbxassetid://1577349"
mesh.Parent = handle
-- Attach the Accessory to the humanoid.
humanoid:AddAccessory(clockworksShades)
end
end)

5 comments
You first need to tell us if it's a script inside a gui, if it's local or not and if it's not in a gui where is it.
It's not a local script, and it's a TextButton
You have loads of syntax errors in your code which will prevent it to run. The code will run in your event in theory, however, the code will not compile.
And it's inside screengui-frame-Textbutton
i need a fix to this script, please.