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

I am attempting to equip a players hat when they enter the game. Ideas?

I am attempting to make a script that adds a hat to the players charcater depending on their last play through. I currently have the value of the currentequippedhat set to 1 as default so it is not a data issue. I get the "not functioning" option in the output instead of printing whats inside the first if statement. What do you guys suggest?


local equipEvent = game:GetService("ReplicatedStorage").RemoteEvents.EquipHat

local BasicFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.BasicFedora
local BlackStripedFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.BlackStripedFedora
local GreenFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.GreenFedora
local FancyFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.FancyFedora
local BaseballCap = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.BaseballCap

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if player:WaitForChild("leaderstats"):WaitForChild("PlayerStats").CurrentEquippedHat.Value == 1 then
			print("Hat 1 is equipped")
			char.Humanoid:RemoveAccessories()
			char.Humanoid:AddAccessory(BasicFedora:Clone())
		else
			print("not functioning")
		end
	end)
end)

2 answers

Go to the Home tab on roblox studio and on the right you will see a button that says Game Settings click on that and click the Avatar tab, you will see many options for the players avatar, have fun!!

2 comments

0

-1 , a constant hat isn't going to help at all in the case of a saving and loading hat load system.

0

no need to be rude and down vote the question ;-;

Instead of doing character:AddAccessory() just parent the accesory to the players character like this:

    print("Hat 1 is equipped")
	            char.Humanoid:RemoveAccessories()
                    BasicFedora:Clone().Parent = char
	        else
	            print("not functioning")
	        end

3 comments

0

-1, payback cause your rude

0

oh no, i downvoted your answer because it didn't help at all, i'm such a horrible person huh

0

yours didnt help at all ;-;

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