Hi guys!
I’m currently creating a new simulator game. I want to make the player to be able to destroy for example coins, chest etc. Once they do that, there will be orbs falling out of the part until it breaks.
I already have a script to make the player walk to the part once they click on it.
But I don’t have a clue how to make the part destroyable and that there are orbs coming out, just like pet simulator x.
Hopefully you guys can help me!
Thanks in advance!
Simple! Alright, so you need an understanding in parts, and I expect at least some code to be done. Otherwise, we have some learning to do.
Let me answer your questions one by one.
So, this is probably the simplest thing. You can use Instance.new("Part")
to create a new part, and then set the Position
and Shape
of the part, with Vector3
and Enum.PartType.Sphere
, but again this is after it is destroyable. So, to make it destroyable, I would recommend a health value. There’s many different ways of coding it so I’ll leave it up to the other replies to get that working. I just told you what to do, but you need to figure out how with either the other replies or some Roblox documentation on APIs.
Is that the only question? You don’t want to ask what should happen after it is destroyed? Seems like a waste of a strong topic. Being more specific on what help you need always gets your topic more replies, because for some of the other developers (not me) it is hard to find a generic reply to find the problem or find a solution.
3 Likes
We can’t give you the code… But I will give you the idea What you could do is add an IntValue into the Chest Called HP Make a cooldown like .5 secs Each .5 secs Make the hp less by 1 Once it reaches 0 it would destroy, The Orbs falling down is Easy, I don’t need to explain it But if you don’t know Ask me and I’ll tell you How could you do it.
1 Like
Thank you for your Reply.
I already knew how to make the part destroyable, but I mean how to make orbs come out of the part?
Alright, I see. So, after destroying, you can call Instance.new
to create a new Part
. This would look like local orb = Instance.new("Part")
. Then, put that in a for loop, like for i = 1, 10 do
. Inside the for loop, where the orb is defined, you need to assign the shape and position. To do this, you can use orb.Shape = Enum.PartType.Sphere
, and for the position, orb.Position = part.Position
(where part
is the name of the destroyable block). I would add orb.Reflectance = math.random(-1, 1)
for good effects, but you can choose to add it. Finally, add orb.Parent = workspace
and game:GetService("Debris"):AddItem(orb, 15)
to parent and automatically clean up the orb.
1 Like
Thank you! I will try that out right now 
1 Like
Yeah, it works. Thank you!
But I was more seeking like the same effect as Pet Simulator X. (See video below for a reference.)
So that the player is able to pick them up and that the orbs are staying in place and are not going away too far from the destroyed object.
Alright. So what you can do is lerp the Position
of each orb from a spawn
function with a while
loop. Like while orb.Parent do
, and in the function, do orb.Position = orb.Position:Lerp(otherCharacter.HumanoidRootPart.Position, 0.1)
or something like that. You need to add a wait
statement. You can also use TweenService
to make the position bounce more fluidly.
1 Like