of     1   

koopa
#19266Monday, March 19, 2007 6:12 PM GMT

Lol, so yeah i have been making a little explosive gas tank thingy for the past couple of minutes, and i think i have my script down correctly and it says i have no errors in the output window. The problem is it doesnt work, as usual, and obviously i wouldnt bother posting something about it if it wasnt working. In this script i am using the timesHit stuff, i practiced a little bit wiht that stuff on another of my projects, it is very neato. So anyways here is the script. The purpose of this, is after 20 times being touched it will just explode... pretty basic, there is actually more to it but thats the only part that is having the problem... print("Wear Down and Explode Script Loaded") GasTank = script.Parent Gas = game.Workspace.GasTanks.Gas6 local timesHit = 0 function onTouched(hit) timesHit = timesHit + 1 print("Uh-Oh") end if timesHit > 20 then function blow() explosion = Instance.new("Explosion") explosion.BlastRadius = 12 explosion.BlastPressure = 1000000 explosion.Position = script.Parent.Position explosion.Parent = game.Workspace GasTank.Position = Vector3.new(0,-100,0) Gas.Position = Vector3.new(0,-100,0) connection:disconnect() end end connection = GasTank.Touched:connect(onTouched) So this doesnt work.... i have not found out the reason why it doesnt work either... duh, lol. I was also wondering if there is a easier way to get rid of a piece, like in my lines right after the explosion part, i am moving the GasTank and Gas to (0,-100,0). I am doing that because i want to get rid of them. I think i remember something like :remove() or something like that, and i think it takes the peice out... i am not sure about that though. There are my Q's please feel free to answer lol. I should probably publish this too..... Koopa
ThunderStealth
#19321Monday, March 19, 2007 9:19 PM GMT

I believe that you may need to put the debounce feature in the script. As far as I can see in this script, the event would be fired multiple times, like how PenguinArmyBase's script was acting. And about the :remove(). Yes, that completely removes the model from the game, so change it to :remove() instead of using Vector3.new to move them out of sight.
ThunderStealth
#19322Monday, March 19, 2007 9:28 PM GMT

By the way, if you add the debounce feature, try making a small time period before turning debounce to False again. Here's an example: _____________________________________________________________________ debounce = true timesHit = timesHit +1 print("Uh-Oh) wait(1) -- Small time period before turning off debounce debounce = false end _____________________________________________________________________ Kinda of like that. Then if it gets touched, it'll wait for a second before being able to get another timesHit count. I'm sure you probably know this already, but at least others will know about it now.
koopa
#19323Monday, March 19, 2007 9:34 PM GMT

Ok, i will try that debounce stuff, thanks for the help ThunderStealth! Koopa
ThunderStealth
#19325Monday, March 19, 2007 9:39 PM GMT

No problem. Pilot
koopa
#19379Tuesday, March 20, 2007 7:09 PM GMT

Ok, well i tried what you said Pilot, and i dont get a error message or anything so it is working but still not. I am still not getting a explosion... Here is the updated script. print("Wear Down and Explode Script Loaded") GasTank = script.Parent Gas = game.Workspace.GasTanks.Gas1 local timesHit = 0 function onTouched(hit) debounce = true timesHit = timesHit +1 print("Uh-Oh") wait(1) debounce = false end if timesHit > 20 then function blow() explosion = Instance.new("Explosion") explosion.BlastRadius = 12 explosion.BlastPressure = 1000000 explosion.Position = script.Parent.Position explosion.Parent = game.Workspace GasTank.Position = Vector3.new(0,-100,0) Gas.Position = Vector3.new(0,-100,0) connection:disconnect() end end connection = GasTank.Touched:connect(onTouched) I am not quite sure what is wonrg with it now... i am thinking that maybe is has something to do with the explosion = Instance.new("Explosion") part. Anyone got any ideas?
MrDoomBringer
Top 100 Poster
#19382Tuesday, March 20, 2007 7:59 PM GMT

Put in a lot of print("(whatever)") messages everywhere, so you know what works, untill it stops working. Also, instead of GasTank.Position = Vector3.new(0,-100,0) Gas.Position = Vector3.new(0,-100,0) moving them, just put GasTank:remove() Gas:remove() and that should be less laggy than waiting for it to hit -500.
PilotLuke
#19390Tuesday, March 20, 2007 8:26 PM GMT

This may not help with the explosion, but having a text around the gas tank references saying "local debounce = false" MIGHT help.
connorbert
#19412Tuesday, March 20, 2007 9:00 PM GMT

im not a good scripter but at the end of the script at the start has end twice.l maby thats what is not making it work...
koopa
#19418Tuesday, March 20, 2007 9:09 PM GMT

Ah yes, silly me to forget the debounce in the beginning of the script, thanks Pilot... Yes, i am going to do what you said also Doom, thanks for reminding me also, I was kinda busy today so i missed somethings..... Connerbert, it has the end at the bottom two times because it is ending two functions, so those are actually both needed. Thanks guys, now i just need to get that explosion working lol. Thanks Koopa
SonOfSevenless
Top 100 Poster
#19424Tuesday, March 20, 2007 9:55 PM GMT

Actually connerbert is on the right track. You are using functions incorrectly in your code. You define a function using the "function" keyword like so: function printHello() print("Hello") end But when you want to call the function you just do this: printHello() --------------------------------------------------------------------------- Your code needs to look more like this: print("Wear Down and Explode Script Loaded") GasTank = script.Parent Gas = game.Workspace.GasTanks.Gas6 local timesHit = 0 function blow() explosion = Instance.new("Explosion") explosion.BlastRadius = 12 explosion.BlastPressure = 1000000 explosion.Position = script.Parent.Position explosion.Parent = game.Workspace GasTank.Position = Vector3.new(0,-100,0) Gas.Position = Vector3.new(0,-100,0) connection:disconnect() end function onTouched(hit) timesHit = timesHit + 1 print("Uh-Oh") if timesHit > 20 then blow() end end connection = GasTank.Touched:connect(onTouched) --------------------------- That may not work, I have not tried it. But it is closer. Things I changed: * Made onTouch call blow() if touched 20 times - I don't know what you were trying to do before, but it wasn't what you wanted. * Moved blow() so that the function is declared before (higher up in the source code) it is called. This is required in lua. * You had an extra end in there at the bottom that I removed. PilotLuke is probably right - this is a place where you might like to have debouncing, but it is not strictly necessary unless you care if the thing is hit EXACTLY 20 times. - SOS
SonOfSevenless
Top 100 Poster
#19425Tuesday, March 20, 2007 9:56 PM GMT

PS - if it is still not working, publish it to your place and I will copy it and try to get it going. I could use something like this myself.
koopa
#19464Wednesday, March 21, 2007 12:44 AM GMT

Thanks SOS, i will go try those out! Many thanks! Koopa
koopa
#19472Wednesday, March 21, 2007 1:20 AM GMT

Very nice, it now works, just a little more cleaning up to do.... like the remove thing and thats all. Thanks again SOS. Koopa
MrDoomBringer
Top 100 Poster
#19574Wednesday, March 21, 2007 8:50 PM GMT

*rates SonOfSevenless a gold star*
EchoTriplication
#63865149Monday, March 05, 2012 8:03 AM GMT

That looks like a complex scrpt. o_o
RyanDolan123
#116747432Tuesday, October 29, 2013 11:20 PM GMT

@kool That's a very basic script, lol

    of     1