Hello. I am trying to make a button that gives you a hat when you click it. I have made a script wich you can see here;
local plr = game.Players.LocalPlayer
local char = plr.Character
local hat = script.Parent:FindFirstChild("hat")
script.Parent.MouseButton1Click:Connect(function()
local clone = hat:Clone()
local weld = Instance.new("WeldConstraint")
weld.Parent = hat
weld.Part0 = hat
weld.Part1 = char.Head
clone.Anchored = false
end)
but it doesn’t work. I don’t know what I’m doing wrong. This is how my stuff is set up in the explorer
If you need any other details please let me know. Thank you.
local button = script.Parent
local remoteevent = -- path to remote event, must be in replicatedstorage
button.MouseButton1Click:Connect(function()
remoteevent:FireServer()
end)
SERVER:
local remoteevent = -- path to remote event, must be in replicatedstorage
remotevent.OnServerEvent:Connect(function(player)
local newhat = hatthing:Clone()
-- all the other stuff
newhat.Parent = player.Character:FindFirstChild("Head")
end)