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)
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!!
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