Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ==Introduction:==
- In this tutorial, you'll be learning how to make an onTouched bomb! Sort of like a mine field type bomb.
- ==Setting It Up...==
- [[File:TheBomb.png|thumb|144px|The Bomb]]
- First, go open up Roblox Studio. Next, go to Insert>Object>Part and change the Shape to Ball/Sphere. Then resize it to actually look like a ball. Then select that part. Go to Insert>Object>Script. Name this script and the part whatever you feel is necessary.
- ==Scripting It!==
- Here, we will learn to script the bomb itself. Let's get started...
- To see if the bomb is touched to activate, we do this:
- function onTouched() --Starts the function so it will activate on touched.
- Now, we have our function, sweet! Let's build the explosion:
- local e = Instance.new("Explosion") --Creates the explosion
- e.Parent = script.Parent --Places location of "Explosion" in the Explorer.
- e.Position = script.Parent.Position --Positions explosion to the bomb.
- e.BlastRadius = 1000 --Shows how big the explosion will be.
- e.BlastPressure = 100000 --How much impact will go into the ranged targets.
- end --Ends the funtion so anything you type after doesn't affect it.
- We aren't finished yet, though! Let's end our function by putting a new line and an "end" then break another line. On our last line, we are going to connect our function so it works:
- script.Parent.Touched:connect(onTouched) --Connects the function so it works
- This tells the bomb (script.Parent) that when it's touched that it needs to do something.
- ==The finished Script==
- [[File:EditedExplosion.png|frame|Explosion after the bomb is done.]]We will now show you what the script looks like when it's done.
- function onTouched()
- local e = Instance.new("Explosion")
- e.Parent = script.Parent
- e.Position = script.Parent.Position
- e.BlastRadius = 1000
- e.BlastPressure = 100000
- end
- script.Parent.Touched:connect(onTouched)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement