Hello,
I’ve looked all around the internet to find a tutorial for giving roblox gear via script but I cannot find one. (Gear meaning actual gear you can put on, not tools.) Could someone either please help me direct a source or help me script something where when a player clicks a button, it equips them with gear.
I know this may be complicated as gear can be welded to certain parts of the body and can contain different elements.
Alright, I put this script under StarterCharacterScripts like it asked for, and defined a button within a GUI, and made it so when the button is clicked, it should use the humanoid:AddAccessory to add the accessory to the player. This did not work for some reason. Any idea why?
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local button = game.StarterGui.ToolsUI.ContentFrame:WaitForChild("Headband")
-- Create the Accessory.
local clockworksShades = Instance.new("Accessory")
clockworksShades.Name = "ClockworksShades"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1,1.6,1)
handle.Parent = clockworksShades
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "FaceFrontAttachment"
faceFrontAttachment.Position = Vector3.new(0,-0.24,-0.45)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1,1.3,1)
mesh.MeshId = "rbxassetid://1577360"
mesh.TextureId = "rbxassetid://1577349"
mesh.Parent = handle
-- Attach the Accessory to the humanoid.
button.Activated:Connect(function()
humanoid:AddAccessory(clockworksShades)
end)
You are trying to access the StarterGui’s button, while you should access the PlayerGui’s button, you could do something like this i guess
-- get the player
local player = game.Players:GetPlayerFromCharacter(playerModel)
-- and get the button via the PlayerGui
local button = player:WaitForChild("PlayerGui").ToolsUI.ContentFrame:WaitForChild("Headband")