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

How do I rapidly change a humanoid's face decal?

I am trying to change a humanoid's face decal fast kinda in a loop. The problem is that every time I have a new decal on, it refreshes the whole character (turns grey and loads the shirt and pants again)

and btw surfacegui+imagelabel do NOT help replace the decal, because it ineeds to be a round face

here is my script so far it is the child of the face decal

count = 0
local pic0 = "http://www.roblox.com/asset/?id=153633352"
local pic1 = "http://www.roblox.com/asset/?id=153632933"
local pic2 = "http://www.roblox.com/asset/?id=153632938"
local pic3 = "http://www.roblox.com/asset/?id=153632945"
while true do
count = count + 1
if count == 1 then
script.Parent.Texture = pic0
elseif count == 2 then
script.Parent.Texture = pic1
elseif count == 3 then
script.Parent.Texture = pic2
elseif count == 4 then
script.Parent.Texture = pic3
elseif count == 5 then
script.Parent.Texture = pic2
elseif count == 6 then
script.Parent.Texture = pic1
elseif count == 7 then
script.Parent.Texture = pic0
count = 1
end
wait(0.1)
end

1 answer

✓ Accepted answer

My immediate suggestion is to make the player's actual head invisible/smaller (new/modified mesh?) and weld onto the character a psuedo-head that is not part of the character to apply the faces to.

Also, your code could benefit in a few ways.

  1. "http://www.roblox.com/asset/?id=" can be accomplished using "rbxassetid://" so each of your assets can be referenced with less code.

  2. You're repeating "rbxassetid://" several times, even though it's the same for all of the assets. This ought to be applied when setting the decal, except --

  3. You're repeating the same code over and over when a table + loop would be much more effective. When you find yourself numbering variables and it ends up more than 3 different ones, or have, like you do, chains of checking against increasing values, you should be using a loop.

local pic = {153633352,153632933,153632938,153632945};
local animation = {1,2,3,2,1};

while true do
	for count = 1,7 do
		script.Parent.Texture = "rbxassetid://" .. pic[ animation[i] ];
		wait(0.1);
	end
end

4 comments

0

Thanks for helping me make it shorter, but I really need Ideas of how to make that pseudo head. Do you know a good guide on welding?

0

In this case it's actually very simple, since C0 and C1's default of the origin CFrame is all you need. Just create the Weld, set Part0 to one head, Part1 to the other (just a :clone() of the first) and parent the weld somewhere.

0

would it hurt to ask, what is c0, c1, part0, and part1

0

C0 and C1 are CFrames describing the position / direction change between the parts. Part0 and Part1 are the two parts being snapped together.

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