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

How to convert this to have multiple decal ID's?

It's part of my blood splattering code and it's decal-based. I simply need this converted to use a table (for random decal IDs that I have to put in myself.)

And I would like some helpful feedback in the code as well, such as how the tables communicate with the ID of the decal and stuff like that.

The code I posted is from my script which is over 80 lines long

			local Decal = Instance.new("Decal")
			Decal.Face = Enum.NormalId.Bottom
			Decal.Texture = "http://www.roblox.com/asset/?id=399737966"
			Decal.Parent = blood

1 answer

✓ Accepted answer

Sure

First, let's make the table of IDs. This is pretty straight forwards and doesn't need explanation.

local ids = {
	"http://www.roblox.com/asset/?id=399737966";
	"Random ID";
	"Random ID";
	"Random ID";
	"Random ID"
}

local Decal = Instance.new("Decal")
Decal.Face = Enum.NormalId.Bottom
Decal.Texture = "http://www.roblox.com/asset/?id=399737966"
Decal.Parent = blood

Now to get a random ID from the table, just use math.random on the index with the max number being the size of the table. Example,

local ids = {
	"http://www.roblox.com/asset/?id=399737966";
	"Random ID";
	"Random ID";
	"Random ID";
	"Random ID"
}

local Decal = Instance.new("Decal")
Decal.Face = Enum.NormalId.Bottom
Decal.Texture = ids[math.random(#ids)]
Decal.Parent = blood

Good Luck!

If I helped, please don't forget to accept my answer!

2 comments

0

This worked flawlessly, wf. I never realized how easy it was to do something like this. Anyways, I'd upvote, but my reputation is terrible from the questions I posted in the past which weren't very good. Anyways, thanks again! :)

0

Thanks. I would honestly love to see you move up and succeed, so keep at it.

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