Advertisement
TheFlamingBlaster

explosion

Aug 29th, 2016
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1. -- TheFlamingBlaster == User 5411
  2. -- User 7870 - electroz
  3. -- User 5364 - C00l
  4. --Electroz: Ok, so hi Cool, I think what we should do is basically make a couple of scripts from the very beginning, I personally say lets go for firstly something simple like a tool that explodes when clicked. Sound good?
  5. -- Crip: Yeah
  6. -- Flaming: Sure, that'd be pretty cool. I'll show you some of the wikipages too. The wiki is super useful for this crap.
  7. -- Crip: any way of targetting localplayer it keeps erroring when i make a localscript
  8. -- Crip: i dont know any thing a local variable but i try to understand what happens
  9. --Electroz: Ok, so to start out lets actually define some variables that will help us do this.
  10. -- Flaming: Let's get some room to code, 100 line? No I always use enter
  11. --Electroz: So, crip, do you know the difference between local variables and global
  12. -- Crip : yeah that makes sense
  13. --Electroz: Variables fast
  14. --Crip: but if p is a part then how come plr.Backpack is only back does p automatically become part? or do you do part = p?
  15. -- Flaming We call the function with p as the argument. I also know how explosions work. Let me take over for a sec.
  16. -- Crip:im not getting mainPart = Instance.new("Part",tool) why do we need to add tool to the end? why cant we just write ("Part")
  17. -- Crip: can we make the tool explode on a certain location?
  18. -- Flaming: Let me add some more comments. We can use the Mouse.hit.P to figure out where the part is.
  19. -- Crip: but what i really wana work on is a weapon but first i guess its the baby steps
  20. -- Flaming: We must start at the beginning, all code is universal.
  21. -- Crip: how do i target localplayers health i thought it was Wweork desfined plr earlier, that represents game.Players, we can then use plr.Character.Humanoid oh
  22. -- Crip: i knew im so shit lol
  23. -- Crip: what think i can do with this is target the local player or plr and then set a force field on click so the player doesnt die
  24. -- Sure, we can do that. With the tool.Activated property
  25. -- Crip: i wana also target the player's shoulders so he does a little bit of a animation like at a CFrame that makes his hands go up
  26. -- Crip: but to target the players shoulders we have to do uhh plr.character.RightArm.Rightshoulders = RS and left for LS ;0 but did i write it correct? Nearly, the variable name = comes first, so it would be RS = oh xDplr.Character.RightArm.RightShoulder
  27. -- Sure we can animate it, we can make them constantly go up and down, as if the character was breathing!
  28. -- Looks like we have got a useable script pretty much. I'll load it up in studio and post the resaults on discord.
  29. -- is there als
  30.  
  31. plrs = game:GetService('Players')
  32. local plr = plrs.LocalPlayer-- Flaming: Now, if this was declared in a function, it wouldn't be able to interact with something outside of that function. This is very useful for interger timers
  33. back = plr.Backpack
  34. tool = Instance.new("Tool",back) -- This makes a new tool inside the local players backpack and sets a variable called "tool" as a reference to the tool we created, that make sense?
  35. tool.Name = "Bomb" -- Sets the tool's name to bomb
  36. tool.ToolTip = "A tool that explodes when you click!" -- When you hover over the
  37. tool.RequiresHandle = false
  38. function makemainpart()
  39. local mainPart = Instance.new("Part",tool) -- This makes the parent property "tool" without us having to supply tool.Parent = mainPart after it. It simplifies code and is useful.
  40. mainPart.Transparency = 0
  41. mainPart.BrickColor = BrickColor.new("Really Black")
  42. mainPart.Material = "Neon"
  43. return mainPart
  44. end
  45. active = false
  46. countdown = 5
  47.  
  48. function explode(p) -- We now create a function to do stuff for us, p is a part
  49. local explosion = Instance.new("Explosion",p) -- This will add a new explosion in the part.
  50. explosion.Position = p.Position -- We're setting the Vector3 Value of explosion to the part's area in the map.
  51. return explosion -- When we return a value, it will act as if we supplied the code in the beginning, such as local explosion = explosion(part) explosion.Name = "BOOM!"
  52. end
  53. print('Yay hints') -- test to see if i can even do a little bit of fucking scripting-Crip
  54. function output(msg,...)
  55. local h = Instance.new("Hint",plr.PlayerGui) -- Hints are little black bars on the top of the game. We should put it in playergui so g/c doesn't clear it and it's only visible to you.
  56. h.Name = "BombHint" -- This is what it'd look like in a explorer gui
  57. h.Text = msg -- The text is supplied here.
  58. game.Debris:AddItem(h,... or 2)
  59. return h -- QUick note, anything past a return will not run! Returns stop the function and "returns" a value
  60. end -- We can keep it on game.Players, however, we should use "plr" which we made up
  61.  
  62. tool.Equipped:connect(function()
  63. print("Equipped")
  64. plr.Character.Humanoid.MaxHealth = 1000 -- When it's equipped, up the health
  65. plr.Character.Humanoid.Health = 1000
  66. Instance.new("ForceField",plr.Character) -- Nope, we use Instance.new ohh ok theres no use of adding plr.? see why do we add "ForceField",Plr.characater
  67. -- Thie first argument, "ForceField" says to add a forcefield, the second argument, plr.Character, tells the instance to add the forcefield to the player. oh ok
  68. -- but if we do that it will become abusive :/
  69. -- We could also do local force = Instance.new("ForceField") force.Parent == plr.Character. However, this saves lines, less lines, better loading times and better looking code overall.
  70. -- This is just a good example, it doesn't really matter if it's abusive!
  71. -- ok but i wana make the part do a wait(1) and make it have intervals where it turns red and then black to make it look likes its a bomb
  72. -- can it be done like part.Enum.Color3new = Really red wait(0.5) Part.Enum.Color3new = Really black
  73. end)
  74.  
  75. tool.Unequipped:connect(function()
  76. print("Dequipped")
  77. plr.Character.Humanoid.MaxHealth = 100 -- Lower it when you unequipped
  78. plr.Character.Humanoid.Health = 100
  79. plr.Character:FindFirstChild("ForceField"):Remove() -- This removes the forcefield ;)
  80. -- Nice!
  81. end)
  82.  
  83. tool.Activated:connect(function()
  84. if active then return end -- To stop the tool from exploding if it is about to explode
  85. active = true -- Telling the script the tool is in explode mode!
  86. output("Bomb activated!",1) -- Telling the user it is about to explode
  87. local main = makemainpart()
  88. local mouse = plr:GetMouse()
  89. main.Position = mouse.Hit.p -- The bomb will be placed where the mouse is
  90.  
  91. wait(1)
  92. --[[for i = 0, countdown do
  93. output("Detonating in "..i.." seconds!",1) -- Tell the user when it will explode
  94. wait(1)
  95. end --]]
  96. local exp = explode(main) -- Exploding the tool
  97.  
  98.  
  99. game.Debris:AddItem(exp,2) -- removing the explosion
  100. for i = 0, 100 do
  101. tool.Name = "Bomb "..i.."%" -- This is the cooldown... not the explosion!
  102. wait(0.05)
  103. end
  104. tool.Name = "Bomb"
  105. active = false -- Allowing the tool to be used again
  106. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement