So I'm brand new to LUA coding and Roblox Studio (though I'm familiar with coding in general). I have successfully created and imported my own custom mesh with a texture, a simple apple.
However, I wanted to mess with scripting and attempted to add in a tycoon-style dropper with a button that would drop the apples when you clicked it. After having zero luck getting it to work, I scrapped the dropper and decided on "Click the button and an apple will fall from the sky".
I successfully got a ball to fall from the sky using this code:
function onClicked(playerWhoClicked)
script.Parent.Transparency=1
wait(.1)
script.Parent.Transparency=0
local sphere = Instance.new("Part") -- creates a part
sphere.Shape = Enum.PartType.Ball -- sets the part shape to a ball
sphere.Position = Vector3.new(15,20,10) -- replace x,y,z with where you'd like the ball to spawn
sphere.Parent = workspace -- this sets the Parent of the part to the workspace
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
But after reading and reading about Welding, SpecialMesh, Cloning, CFrames, I. Can. Not. get my apple to spawn. When I click the button, nothing happens.
Here's the mess I currently have right now. Some things I've tried are commented out. You can see that my mesh's ID is rbxassetid://4562211818. The name is "Apple".
function onClicked(playerWhoClicked)
script.Parent.Transparency=1
--Put commands here
wait(.1)
script.Parent.Transparency=0
--If you want the command to activate after the
--button is pressed, put the commands here instead.
--local mesh = Instance.new("SpecialMesh",part) --makes mesh like you make a part
--mesh.MeshType = Enum.MeshType.FileMesh
--mesh.MeshID = "rbxassetid://4562211818" --id of mesh
--local clonedobject = mesh:Clone()
local part = Instance.new("Part",workspace.PartStorage)
part.BrickColor= game.Workspace.DropColor.Value
part.Material=game.Workspace.MaterialValue.Value
local mesh = Instance.new("SpecialMesh")
mesh.Parent = part
mesh.MeshType = "FileMesh"
mesh.MeshId = "rbxassetid://4562211818"
mesh:SetPrimaryPartCFrame(CFrame.new(15,10,10))
--mesh.Position = Vector3.new(15,50,10)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
I just need someone to explain to me how to make this happen as straightforwardly as possible, ideally with explanations of what is supposed to go where and what it does so I can work with this more in the future. I don't get it at all.
I'd like to make my own worlds in the future and use a lot of, if not mostly, my own custom models, so I need to learn how to work with them.
