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

How to make a Image Button Put a Hat on a players?

Asked by 5 years ago
Edited 5 years ago

I'm wondering how to make a Image button GUI put a hat on a player if you have a answer I will put you in the credits of the game to repay you. Thank you and have a nice day! I'll put the ID and the name of the hat if needed! Oh and beneath the info ID of the hat and name if needed is the code I tried! Sorry if its bad i'm not good at scripting! |Use if need| This is the ID of the hat ---------> 16725421 This is the name of the hat ---------> Fire Fighter Hazard Mask |Script|

  script.Parent.MouseButton1Click:Connect(click)
 local d = game.Players.LocalPlayer.Character
 local hat = d.Fire Fighter Hazard Mask:Clone()

function click()
   if script.Parent.selected.Visible == true then
    game.Players.LocalPlayer.Character:FindFirstChild("Fire Fighter Hazard Mask"):remove()
    game.Players.LocalPlayer.leaderstats.Hats.Value = 0
    script.Parent.selected.Visible = false
else
     hat:Clone().Parent = d
     game.Players.LocalPlayer.leaderstats.Hats.Value = 1
     script.Parent.selected.Visible = true
  end
end

Answer this question