I’m trying to get a player to wear a space helmet when they interact with a prompt, but it’s spawning where the hat already is (on the mannequin), and it isn’t removing the character’s hats, why?
local player = game:GetService("Players").LocalPlayer
local SpaceShip = workspace:WaitForChild("SpaceShipTest")
local SpaceSuit = workspace.SpaceSuit
local AstronautHelm = game.Workspace.SpaceSuit.AstronautHelmet
local function GiveAccessory(player)
local character = player.Character
local humanoid = character.Humanoid
for _, v in humanoid:GetChildren() do
if v:IsA("Accessory") then
if v.Handle:FindFirstChild("HatAttachment") then
v:Destroy()
end
end
end
local accessory = AstronautHelm:Clone()
accessory.Handle.Anchored = false
humanoid:AddAccessory(accessory)
end
SpaceSuit.HumanoidRootPart.ProximityPrompt.Triggered:Connect(GiveAccessory)