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

Meshes and dropper script?

I have this dropper script here and was wonder how I would make it spawn meshes instead of regular bricks. And also have those meshes randomize between two meshes.

wait(2)
workspace:WaitForChild("PartStorage")


deb = true 
script.Parent.Clicker.ClickDetector.MouseClick:connect(function(wat)
	if deb == true then
		deb = false
			local part = Instance.new("Part",workspace.PartStorage)
			part.BrickColor=script.Parent.Parent.Parent.DropColor.Value
			part.Material=script.Parent.Parent.Parent.MaterialValue.Value
			local cash = Instance.new("IntValue",part)
			cash.Name = "Cash"
			cash.Value = 5 -- How much the drops are worth
			part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.3,0)
			part.FormFactor = "Custom"
			part.Size=Vector3.new(1, 1, 1) -- Size of the drops
			part.TopSurface = "Smooth"
			part.BottomSurface = "Smooth"
			game.Debris:AddItem(part,20) -- How long until the drops expire
			wait(.15)
			deb = true
	end
end)

3 comments

0

It decided to go all weird with the code

0

fixed it

0

I put the code in a lua box thing

1 answer

✓ Accepted answer

This is not the cleanest or best way but it'll work. Put this in an instructed.

This block of code goes right after waiting for PartStorage:

local MeshRandomizer = {1,2} --How every many meshes you have 

----Mesh IDs------
local MeshRandomizer1 = "http://www.roblox.com/asset/?id=" --After =, put the ID of the mesh
local MeshRandomizer2 = "http://www.roblox.com/asset/?id=" --Same thing here. You can put as many MeshRandomizers as possible.

This block of code goes right after stating the material for the part:

			local i = math.random(1, #MeshRandomizer) --Sets the random value
			local mesh = Instance.new("SpecialMesh",part) --Creates the mesh
			if MeshRandomizer[i] == 1 then
				mesh.MeshId = MeshRandomizer1
			elseif MeshRandomizer[i] == 2 then
				mesh.MeshId = MeshRandomizer2
			end

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