After a little help from a member on scripthelpers, I was able to get a script down that gives you things depending on a value, and I have this script right here that should give you a face if you have a value, but it doesn't, no output errors or anything, any help?
local bunchOfFaces = { [1] = "rbxassetid://3224406211", --Face1 [2] = "rbxassetid://3224406505", --Face2 [3] = "rbxassetid://3224406817", --Face3 } game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:Connect(function(character) local d = character:WaitForChild("Head").face local val = player:WaitForChild("leaderstats").Face.Value if val >= 1 then wait(1) if val >= #bunchOfFaces then d.Texture = bunchOfFaces[#bunchOfFaces] else d.Texture = bunchOfFaces[val] end end end) end)
When a child of an Instance is loaded, the children of it may not load immediately, especially ones that took time to load like a player's character. Therefore, using local d = character:WaitForChild("Head").face
may not be the most efficient way to do.
To solve this, set the local variable d
to only wait for the charater's Head instead of indexing its face directly by the dot operator. (local d = character:WaitForChild("Head")
). Since you yielded the code for 1 second, you can edit line 14 and line 16 to:
d.face.Texture = bunchOfFaces[#bunchOfFaces] --line 14 d.face.Texture = bunchOfFaces[val] --line 16 --A second is enough time for the decal to be added after the head was replicated.
You can also wait for the face to load, too!
--This is just a reference. local f = d:WaitForChild("face") f.Texture = bunchOfFaces[val]
Cheers! c: