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

How to make a face changer gui button?

Ok, so, I'm making a customize option for my game, and it includes a face changer GUI. I'm using a custom "StarterCharacter." On the dummy I put a custom face, and named it accordingly. I tested and found this script worked.

function onTouch(part)

local humanoid = part.Parent:FindFirstChild("Humanoid")

if (humanoid ~= nil) then -- if a humanoid exists, then

humanoid.Parent.Head.face.Texture = script.Parent.Decal.Texture

end

end

script.Parent.Touched:connect(onTouch)

script.Parent.Touched:connect(onTouch)

Instead of a part being touched though, its a GUI button that will be clicked to change the players face. This is one script I tried, but didn't work.

local humanoid = game.Player.LocalPlayer.Character

script.Parent.MouseButton1Click:Connect(function()
humainoid.Head.face:Destroy()
humainoid.Head.face.Texture = "rbxassetid//10907551"
end)

Any help why this isn't working? I'm new to Roblox Studio, so I'm still learning, bear in mind that when you see my bad scripting skills :P

2 answers

✓ Accepted answer

Ok, so i think your issue is that you're setting humanoid's value to a character that doesn't yet exist (meaning your trying to get the character before it's even loaded in), a way to fix this would be to change the first line to:

local Humanoid = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

however, if you're looking to make the face show for everyone else in the server you'll have to know how to use RemoteEvents if you're making a single player game you can use the above method, if you're making a multiplayer game however, i'd reccomend learning Roblox Studio some more before attempting to unerstanding, if you don't wanna wait that long, you can always search the roblox API Reference for RemoteEvents an you'll get more info there.

Peace boi

from de FlabbyBoiii

4 comments

0

that line of code is all to be put on a single line by the way

0

So, this would work for only if one person is in the game? It's a multiplayer game so I guess I try RemoteEvents. I do, however, have a little understanding how to use RemoteEvents.

0

Thanks anyway!

0

no problem by the way (I haven't been here in ages), and I've just realised how cringey I was just seven months ago. Hope you got there in the end :)

I am seeing this, and i see it was posted 10 months ago but idc, you destroyed the face so there is no face to edit

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