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

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

Asked by 10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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

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? randomsmileyface 375 — 10y
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. BlueTaslem 18071 — 10y
0
would it hurt to ask, what is c0, c1, part0, and part1 randomsmileyface 375 — 10y
0
C0 and C1 are CFrames describing the position / direction change between the parts. Part0 and Part1 are the two parts being snapped together. BlueTaslem 18071 — 10y
Ad

Answer this question