How do I script an explosion to repeat the explosion effect on a certain part(s) as long as another certain script is running/enabled?
Use a While True do loop! This will keep playing until you break it
I have tried that, but it only exploded once, then stopped.
did you ever try Cloning and destorying it?(i’m new but this is a way i would do it but i think u can do that)
Something along the lines of this could work:
while wait(1) do
local explosion = Instance.new("Explosion")
explosion.Parent = part
--You can configure the explosion's properties here
end
Yeah, that would work, however, I’m using it in a meltdown-like thing for a research facility, and it has code that needs to happen after the explosion, and I tried making the click detector run the script, but it didn’t work then.
I need the explosion to only happen when a certain script is running, though.
Then use a bool Value and when it is fals/true then it will work or use if staement.
Ah I see. So I just make it run at the same time as the click detector runs the meltdown script?
So you can add an if
condition to see if the script is enabled. This would not be an efficient option, so I suggest storing a value in the server to handle the explosion toggle
Ah. I’m not familiar with storing values or any of those things, so how would I do that? I understand the script parts.
BoolValue allows data be sent over the game so it will store the data until changed !(my way of defining it)
There is other values that can help u too,For Example intNumber
So, what you’re saying is, have a value in the server waiting, and then when the certain script is running, have a certain line in the script that makes that value true, then the explosion runs?
yup thats right and so then you can run the script
I’m not aware of your situation and when the said script should be disabled or enabled, but you can create a variable stored in the server and call a remote event every time the explosion is toggled.
It could look something along the lines of:
local ExplosionIsOn = false
RemoteEvent.OnServerEvent:Connect(function(Player, Toggle)
ExplosionIsOn = Toggle --The toggle being a bool value which can be set from the client
end)
while wait(1) do
if ExplosionIsOn == true then
local explosion = Instance.new("Explosion")
explosion.Parent = part
--You can configure the explosion's properties here
end
end
Where would I add the remote function to? I’m not familiar with where these things go.
So that is just a generalized piece of code that yours could end up looking like. It’s up to the developer to figure out how I can do this and why I need to do this, but I want to lead you in the right direction If you are unsure as to how to use remote events/functions, there are many great sources that can explain in depth as to how you can use them and why you should use them.