I Was Making Hat Tools, Not Working

I Was Making Hat Tools That When Activated Tools, It Give Hat To Character, And When Activate It Again, It Remove Hat From Character

But For Some Reason, When I Tested, It Not Working, There Is No Error In Outputs.

Tool Script

local hat = script.Parent
local event = game.ReplicatedStorage.Hatevent

hat.Activated:Connect(function(player)
	event:FireServer(player)
end)

Event Script

local event = game.ReplicatedStorage.Hatevent
local hatitself = game.Lighting.Hat["Ben's Decent Cowboy Hat"]

notwear = true

event.OnServerEvent:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
	
--- If Not Wearing
	if notwear then
	notwear = false
	local a = hatitself:Clone()
		a.Parent = character	
		a.Name = "ServerHats"
	end
--- If Wearing
	if not notwear then
		notwear = true
		local hat2 = character:FindFirstChild("ServerHats")
		hat2:Destroy()
	end
end)

instead of using notwear just check if the hat is in the character

also make sure the hat actually works so test it on an npc or something

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.