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

I can't seem to get my face changing script to work, can somebody point out why this may be?

So basically I'm making a face changer UI, And the code linked worked fine. Until I tried to show my friend it in a game, Which then, he didn't see my changed face. So I thought the script being a local script was the problem, So i made it a regular script and now i get this

Players.andypop12345.PlayerGui.FaceChangeUi.FaceChange.AngrySadE.ImageButton.Script:5: attempt to index nil with 'Name'

Here's the script I attempted to use

local player = game.Players.LocalPlayer
local face = "http://www.roblox.com/asset/?id=5965483051"

script.Parent.MouseButton1Down:Connect(function() 
	game.Workspace[player.Name].Chest.FaceHere.Face.Texture = face
end)

Line 5 is the line that's giving the error And feel free to just give me the code if you want, but that's lazy me talking, I want to learn how to script better and stuff so try just point out why its not working instead of just giving me the solution.

3 comments

0

Also i don't know why it says the face doesn't exist, cause it still works.

0

Your script is not Filtering Enabled, it means your face only changes on client and not server-wide.

0

You will require RemoteEvent/RemoteFunction here, you can lean how to use them in YouTube tutorials. https://developer.roblox.com/en-us/api-reference/class/RemoteEvent

1 answer

I think what is happening is that the script is looking for the face when it has not loaded, Roblox avatar parts do not load instantly, they load when they decide to

local player = game.Players.LocalPlayer
local face = "http://www.roblox.com/asset/?id=5965483051"

script.Parent.MouseButton1Down:Connect(function() 
  local facepart =   game.Workspace:WaitForChild(player.Name):WaitForChild("Chest"):WaitForChild("Face")
facepart.AssetId = face
end)

hope this helped! if not please let me know

3 comments

0

I tested this script out in my game, with both a local and normal script, I got this, " Infinite yield possible on 'Workspace.andypop12345.Chest:WaitForChild("Face")'" It definitely seems like an improvement though! I'll tinker around with it a bit and see if it works then. Thank you!

0

to remove this error, add a timeout to each :WaitForChild like this: game.Workspace:WaitForChild(player.Name,9999):WaitForChild("Chest",9999):WaitForChild("Face",9999) facepart.AssetId = face

0

I did that and i got this Players.andypop12345.PlayerGui.FaceChangeUi.FaceChange.AngrySadE.ImageButton.LocalScript:6: attempt to index nil with 'AssetId'

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