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

Script that randomizes the asset id of the face in a humanoid on spawn?

I've been trying for a while now with no success to make it work on a server, to no prevail. This was my best attempt, what did I do wrong? I looked everywhere too, nothing I could find.

local players = game:GetService("Players")

local faceIDs = {"6490065277", "6490481912", "6490491627", "6490495328", "6490543849", "6490546626"} 

faceID = faceIDs[math.random(1,#faceIDs)] 

local function onCharacterAdded(character)
	script.Parent.Texture = "rbxassetid://"..faceID
	
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

players.PlayerAdded:Connect(onPlayerAdded)

(belongs in the face decal of a StarterCharacter)

1 answer

how about inside the startercharacter, you place a Folder called "Faces" then put a lot of decals called face with the faceid's on each of the face decals. then you do this script

local faces = game.StarterPlayer.StarterCharacter.Faces:GetChildren()
local rand = Random.new() 
local num = rand:NextInteger(1,#faces) 
local chosen = faces[num]


game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		chosen.Parent = chr.Head
	end)
end)

3 comments

0

in the onCharacterAdded function

0

Tried it, same result. Face decal stays the same.

0

i've made a different script, does it work now?

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