Tycoon Dropper drop Mesh

I have this code below that spawns in a new part that has a specific value (cash) but how can I change that part into a mesh? The part spawn location is .SpawnPart

local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts

while wait(2) do
	local NewPart = Instance.new("Part",DropperPartsFolder)
	NewPart.Position = script.Parent.SpawnPart.Position
	NewPart.Size = Vector3.new(1,1,1)
	
	local CashValue = Instance.new("NumberValue",NewPart)
	CashValue.Value = 1
	CashValue.Name = "CashValue"
end

Instead of using Instance.new, it would be easier to put your precreated drops into ServerStorage, and then clone them so you can customize them all you want.

You need to create a new mesh inside of the part, here’s how.

local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts

while wait(2) do
	local NewPart = Instance.new("Part",DropperPartsFolder)
	NewPart.Position = script.Parent.SpawnPart.Position
	NewPart.Size = Vector3.new(1,1,1)

	local mesh = Instance.new("SpecialMesh", NewPart)
	mesh.MeshType = Enum.MeshType.FileMesh
	mesh.TextureId = "" -- set to TextureId
	mesh.MeshId = "" -- set to MeshId

	local CashValue = Instance.new("NumberValue",NewPart)
	CashValue.Value = 1
	CashValue.Name = "CashValue"
end
1 Like

It works but I ran into a problem where I cannot see the mesh.

Did you put in the texture id and the meshid?

both ids are in correctly. Do I need a model of the mesh in workspace?

Step 1: Create a MeshPart in studio and upload the desired mesh.
Step 2: Keep the part somewhere in storage (below script does it on ReplicatedStorage)
Step 3: Clone that part from storage and drop it

Here is an example below:
Note: Change the “MyMeshPartName” reference to your mesh name on the desiredMeshPart variable

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts

local desiredMeshPart = ReplicatedStorage.MyMeshPartName

while task.wait(2) do
        local NewPart = desiredMeshPart :Clone()
        NewPart.Parent = DropperPartsFolder
	NewPart.Position = script.Parent.SpawnPart.Position
    --NewPart.Anchored = false -- uncomment if your mesh part is anchored
	--NewPart.Size = Vector3.new(1,1,1)
	
	local CashValue = Instance.new("NumberValue",NewPart)
	CashValue.Value = 1
	CashValue.Name = "CashValue"
end

Maybe try removing “mesh.MeshType = Enum.MeshType.FileMesh”. I’m not sure why the mesh does not work, you could also try cloning a mesh you already have from something such as the serverstorage, lighting, replicated storage, etc.

The problem I am currently having is the collector is not destroying the meshes.

local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue

script.Parent.Touched:Connect(function(Hit)
	if Hit.Name == "RobloxVisor2007" and Hit:FindFirstChild("CashValue") then
		CashValue.Value += Hit:FindFirstChild("CashValue").Value
		Hit:Destroy()
	end
end)

Is “Hit” the MeshPart in this case? Because if so, make sure your mesh name is “RobloxVisor2007” and there is a cash value inside of the mesh.

Currently getting this error Workspace.TycoonModel.Boughtitems.FirstDropper.Script:14: attempt to call a Instance value

from this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts

local desiredMeshPart = ReplicatedStorage.RobloxVisor2007


while task.wait(2) do
	local NewPart = desiredMeshPart :Clone()
	NewPart.Parent = DropperPartsFolder
	NewPart.Position = script.Parent.SpawnPart.Position
	--NewPart.Anchored = false -- uncomment if your mesh part is anchored
	--NewPart.Size = Vector3.new(1,1,1)

	local CashValue = NewPart("NumberValue",NewPart)
	CashValue.Value = 1
	CashValue.Name = "CashValue"
end

I’m most positive adding cash value into the mesh fixed it. I appreciate everyone that helped!

1 Like

I know this has been solved, but here is just a little example I created.

MeshDropperTest.rbxl (142.7 KB)

image
image

local DropPart = game.ReplicatedStorage.DuckDrop

while true do
	local drop = DropPart:Clone()
	
	drop:SetAttribute("Money",10) --set each drop to 10 value
	
	drop:PivotTo(script.Parent.CFrame)
	drop.PrimaryPart.Anchored = false
	local color = BrickColor.random()
	drop.Duck1.BrickColor = color
	drop.Duck2.BrickColor = color
	
	drop.Duck1.Transparency = 0
	game.Debris:AddItem(drop,5)
	drop.Parent = workspace
	task.wait(1)
end

image

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent.Name == "DuckDrop" then
		local drop = hit.Parent		
		if drop.Duck1.Transparency == 0 then
			
			drop:SetAttribute("Money",drop:GetAttribute("Money")*2) --double the value
			
			drop.Duck1.Transparency = 1
			drop.Duck2.Transparency = 0 
		end
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.