Accessory script giver

hi my name is abed i want some of help i have script not local script i want do
if local player value == 1 then it give accessory to player
the script i use


Hat = game.ReplicatedStorage.AngelWR
Hat1 = game.ReplicatedStorage.AngelWL
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Hat:Clone().Parent = Character
		Hat1:Clone().Parent = Character
	end)
	end) 

1 Like

I am not quite understanding what you are trying to do. Do you have a Value Object inside the Player Object? What is the name of that Value Object?

1 Like

value for data store and i want do script when the value be 100 then clone part

What is the name of the Value? And where is it parented?

race and the value in it change from spin

i want do if player get race angel he get new accessory it wing

hard to make out what your saying but i think i might know what you are saying

when the character is loaded in, check if the value is 1 with

if value == 1 then
	-- code
end

so in your case you said the value’s name is race, so you make a variable of that at the top of the script then reference it, replacing value

Okay so try using this code for your script:

Hat = game.ReplicatedStorage.AngelWR
Hat1 = game.ReplicatedStorage.AngelWL

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if player:FindFirstChild("race").Value == 1 then
			Hat:Clone().Parent = Character
			Hat1:Clone().Parent = Character
		end
	end)
end)

Wdym Value == 1?

This text will be blurred

not work it dont know why mabye i put the value in file

https://gyazo.com/de04667bb6bc5b793f9aa9a285c18bb6

I see now, try using this code for your script:

local Hat = game.ReplicatedStorage.AngelWR
local Hat1 = game.ReplicatedStorage.AngelWL

game.Players.PlayerAdded:Connect(function(Player)
	local PlayerData = Player:WaitForChild("PlayerData")
	local InfoFol = PlayerData:WaitForChild("Info")
	local RaceValue = InfoFol:WaitForChild("Race")

	Player.CharacterAdded:Connect(function(Character)
		if RaceValue.Value == 1 then
			Hat:Clone().Parent = Character
			Hat1:Clone().Parent = Character
		end
	end)
end)
1 Like

not work i dont know why i will try again

I found a mistake in the code, I have just edited it. Try using the code again. Also, are you receiving any errors in the output? If you are could you please let us know what errors you are getting

still not work and output there nothing say there are problem

do if i use starter character that make problem

and i use script not local script i know playeradded for local script

Humanoid has a function called AddAccessory that handles the accessory add on for you. Should only ever be done through a Script.

Hat = game.ReplicatedStorage.AngelWR
Hat1 = game.ReplicatedStorage.AngelWL

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local humanoid = Character.Humanoid or Character:WaitForChild("Humanoid", 3)
		local newHat = Hat:Clone()
		local newHat1 = Hat1:Clone()

		humanoid:AddAccessory(newHat)
        humanoid:AddAccessory(newHat1)
	end)
end)

i know that but i need player may have value

Where are you storing the folder with your values? I would say make a new folder for your values and store it in StarterPack.
image

image