Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Items reset when i spawn. how can i keep the items morph when reset?

local debounce = true

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local HumanoidDescription = character:WaitForChild("Humanoid"):WaitForChild("HumanoidDescription")
        local ID = 64082730 -- The Rainbow Shaggy ID.
        if character.Name == "Playername" and debounce == true then -- Replace "Playername" with the name you want to spawn with the Hair.
            debounce = false
            wait(0.5) -- Keep the wait, as I tested this without the wait it was just an infinite loading screen.
            HumanoidDescription.HairAccessory = ID
            player:LoadCharacterWithHumanoidDescription(HumanoidDescription)
        end
    end)
end)

When i reset the shaggy morph dissapears how can i make it so it stays when i reset charactter aswell?

1 answer

✓ Accepted answer
local Players = game:GetService("Players")
local InsertService = game:GetService("InsertService")

function getAccessoryType(accessoryInstance)
    local attachment = accessoryInstance.Handle:FindFirstChildOfClass("Attachment")
    local accessoryType = attachment.Name:match("(.+)Attachment")
    return accessoryType
end

local HairID = 64082730
Players.PlayerAdded:Connect(function(Player)
	if Player.Name == "forsakern" then
	    Player.CharacterAppearanceLoaded:Connect(function(Character)
			local Humanoid = Character:FindFirstChildOfClass("Humanoid")
			if Humanoid then
				local success, model = pcall(InsertService.LoadAsset, InsertService, HairID)
				if success then
					for _, v in pairs(Humanoid:GetAccessories()) do -- Removes existing hair
						if getAccessoryType(v) == "Hair" then 
							v:Destroy() 
						end 
					end
					model.Parent = workspace
					Humanoid:AddAccessory(model:GetChildren()[1])
					model:Destroy()
				end
			end
		end)
	end
end)

1 comment

0

OMG THANKYOU UR THE BEST!!!

This discussion is preserved as it was. New answers, comments, and votes are closed.