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

How can I make a hat giver surface gui?

Asked by
iSEANxo -1
7 years ago

I'm trying to make a Surface GUI button which makes the player wear a hat when it is clicked. Here's what I've tried so far -

script.Parent.MouseButton1Click:connect(function()

debounce = true
function onClicked(plr)
if debounce == true then
debounce = false

local h = Instance.new("Hat")
        local p = Instance.new("Part")
        h.Name = "Hat"
        p.Parent = h
        p.Position = plr.Character:findFirstChild("Head").Position
        p.Name = "Handle" 
        p.formFactor = 0
        p.Size = Vector3.new(2, 1, 1)
        p.BottomSurface = 0 
        p.TopSurface = 0 
        p.Locked = true 
        script.Parent.Mesh:clone().Parent = p
        h.Parent = plr.Character
        h.AttachmentPos = Vector3.new(0,.8, 0)
        wait(5)
        debounce = true

end
end
end)


script.Parent.ClickEvent.OnServerEvent:connect(onClicked)

Anyone know how to fix this?

0
Something that you could do to make this way smaller, you could place the hat that you want in server storage, then you could make so that the hat in serverstorage clones, then moves into the player model at the right position.. Because at the moment, your script is creating a new hat.. Also is the Gui on a part in Workspace or its in Starter GUI? starchip12 6 — 7y
0
The surface gui is a part in workspace iSEANxo -1 — 7y

Answer this question