When the player clicks the text button, it changes their hat, but only on THEIR screen.

local player = game.Players.LocalPlayer
local boxes = script.Parent.Parent.Parent.Boxes

function leftclick()
	player.Character:WaitForChild("TopHat").Transparency = 1
	player.Character:WaitForChild("SM64Hat").Transparency = 1
	player.Character:WaitForChild("SmokeyHat").Transparency = 0
	-- these are images
	boxes.Default.Visible = false
	boxes.TopHat.Visible = false
	boxes.SM64.Visible = false
	boxes.Smokey.Visible = true
end
script.Parent.MouseButton1Click:Connect(leftclick)

Why does it not work, and how can I fix it? (I only want the hats to be visible to others, not the images though.) I am gonna try to do a server event, but if it doesn't work then i'll use an answer.