Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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.

0
Also i don't know why it says the face doesn't exist, cause it still works. andypop12345 12 — 3y
0
Your script is not Filtering Enabled, it means your face only changes on client and not server-wide. cherrythetree 130 — 3y
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 cherrythetree 130 — 3y

1 answer

Log in to vote
0
Answered by
TickoGrey 116
3 years ago

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

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! andypop12345 12 — 3y
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 TickoGrey 116 — 3y
0
I did that and i got this Players.andypop12345.PlayerGui.FaceChangeUi.FaceChange.AngrySadE.ImageButton.LocalScript:6: attempt to index nil with 'AssetId' andypop12345 12 — 3y
Ad

Answer this question