So this script I made is supposed to give the player a hat once they click on an imagebutton (the script is inside the imagebutton) But when they click it, they don't get the hat. Would anyone be kind enough to show me what I did wrong?
local replicatedstorage = game:GetService("ReplicatedStorage") local hat = replicatedstorage:WaitForChild("SkullMask") script.Parent.MouseButton1Down:connect(function() wait(1) if(char and plr and char:FindFirstChild("Humanoid")) then for i, v in pairs(char:GetChildren()) do if(v) then if(v:IsA("Hat")) then v:Destroy() end end end local clone = hat:Clone() clone.Parent = char end end) end)
Thanks guys!