Randomizing Textures

  1. What do you want to achieve?

I’m trying to make a vest texture randomizer for my game.


These are the vest variants I came up with. (don’t mind the head placement its some weird glitch that fixes itself in game.)

  1. What is the issue?

I can’t figure out how to do this… It won’t even print what I tried to.

  1. What solutions have you tried so far?

Here’s my code that I came up with to test if I could find the vest inside the character. It’s in the Players Service.
image

Here’s the character layout;
image

local plrservice = game:GetService("Players")

local function CharacterRandomizer(player)
	local char = player.Character
	if char then
		local vest = char:FindFirstChild("Dark Vest")
		if vest then
			print(vest)
		end
	end
end

plrservice.PlayerAdded:Connect(CharacterRandomizer)

If someone could help, I’d greatly appreciate it.

Thanks,
– Luke

OK, I solved it.

image

here is another way :wink:

local textures = {
	"rbxassetid://1234",
	"rbxassetid://1234",
	"rbxassetid://1234",
	"rbxassetid://1234",
	"rbxassetid://1234",
	-- add as many as you like
}
local specialMesh = script.Parent.Vest.Handle.SpecialMesh
specialMesh.TextureId = textures[math.random(#textures)]
3 Likes