Scripting Tutorial #1
I Am Going To Show You How To Make A Landmine
Lets Begin!
Alright So Lets Begin By Making Our Landmine.
I Have made A Basic Landmine, Just For The Tutorial.
So When You Have Made Your Landmine, Dont Group It. Select All The Parts For Your Landmine And Turn It Into A Union. Then Rename It To “Handle”. Dont Anchor It.
When You Have Done That, Insert a Tool. Rename it To “Landmine” Then Put Your Landmine (Handle) Into The tool
Add a Script Into The Handle And Rename it to “ExplodeOnTouch”.
Then Insert This Script:
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Anchored == false then
debounce = true
local explosion = Instance.new("Explosion", workspace)
explosion.Position = script.Parent.Position + Vector3.new(0, 0.6, 0)
explosion.ExplosionType = Enum.ExplosionType.NoCraters
explosion.BlastRadius = 4
explosion.BlastPressure = 12500
wait(0.2)
script.Parent:Destroy()
end
end)
Now That You Have Done That, Lets add A Script Into The Landmine And Rename To “ToolFunction”.
Then Insert This Script Into The ToolFunction Script.
local debounce = false
script.Parent.Activated:Connect(function()
if debounce == false then
debounce = true
local clone = script.Parent.Handle:Clone()
clone.Parent = workspace
clone.Name = "prop.Landmine"
clone.Velocity = Vector3.new(0,0,0)
clone.CanCollide = true
script.Parent.Parent = nil
end
end)
Were All Done, Although We Should Add A Beeping Noise Before The Explosion When Someone Triggers it.
So Insert A Sound Into Handle, Then Rename it To Beep.
Now We Need to Find A Beep Noise.
I Have Found a Really Good Beep Noise And Credits to @Jenrak For Making This Beep.
In The Properties Of Your Sound, Please Have The Same Properties as Me.
Now That We Have the Beep Noise, We Need It To Play When A Player Touches The Landmine. So We have to edit The ToolFunction Script.
Here Is The Edit For The ToolFunction Script:
local debounce = false
script.Parent.Activated:Connect(function()
if debounce == false then
debounce = true
local clone = script.Parent.Handle:Clone()
clone.Parent = workspace
clone.Name = "prop.Landmine"
clone.Velocity = Vector3.new(0,0,0)
clone.CanCollide = true
script.Parent.Parent = nil
wait(0.7)
clone.ExplodeOnTouch.Disabled = false
clone.Beep:Play()
wait(0.3)
clone.Beep:Play()
end
end)
When You Have Finished, Put Your Landmine In The StarterPack. And You Should Be Able To Place It Down And also Blow Up When a Player Steps On It.
If There Are Any Issues You Can Contact Me On Discord (Cup#7777)
See It In Action!!
robloxapp-20200814-2019071.wmv (4.2 MB)
I Had Alot Of Trouble Trying To Make The Landmine Face Straight Up When Its being Held. So You Can Try for Yourself.
Model
What Tutorial Should I Do On Next??
- How To Make A Jetpack
- How To Make a Plane
- How To Make a Premium Only Door
- How to An FPS Counter
- How To Make a Backpack System
0 voters