Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TheFlamingBlaster == User 5411
- -- User 7870 - electroz
- -- User 5364 - C00l
- --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?
- -- Crip: Yeah
- -- Flaming: Sure, that'd be pretty cool. I'll show you some of the wikipages too. The wiki is super useful for this crap.
- -- Crip: any way of targetting localplayer it keeps erroring when i make a localscript
- -- Crip: i dont know any thing a local variable but i try to understand what happens
- --Electroz: Ok, so to start out lets actually define some variables that will help us do this.
- -- Flaming: Let's get some room to code, 100 line? No I always use enter
- --Electroz: So, crip, do you know the difference between local variables and global
- -- Crip : yeah that makes sense
- --Electroz: Variables fast
- --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?
- -- Flaming We call the function with p as the argument. I also know how explosions work. Let me take over for a sec.
- -- 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")
- -- Crip: can we make the tool explode on a certain location?
- -- Flaming: Let me add some more comments. We can use the Mouse.hit.P to figure out where the part is.
- -- Crip: but what i really wana work on is a weapon but first i guess its the baby steps
- -- Flaming: We must start at the beginning, all code is universal.
- -- 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
- -- Crip: i knew im so shit lol
- -- 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
- -- Sure, we can do that. With the tool.Activated property
- -- 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
- -- 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
- -- Sure we can animate it, we can make them constantly go up and down, as if the character was breathing!
- -- Looks like we have got a useable script pretty much. I'll load it up in studio and post the resaults on discord.
- -- is there als
- plrs = game:GetService('Players')
- 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
- back = plr.Backpack
- 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?
- tool.Name = "Bomb" -- Sets the tool's name to bomb
- tool.ToolTip = "A tool that explodes when you click!" -- When you hover over the
- tool.RequiresHandle = false
- function makemainpart()
- 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.
- mainPart.Transparency = 0
- mainPart.BrickColor = BrickColor.new("Really Black")
- mainPart.Material = "Neon"
- return mainPart
- end
- active = false
- countdown = 5
- function explode(p) -- We now create a function to do stuff for us, p is a part
- local explosion = Instance.new("Explosion",p) -- This will add a new explosion in the part.
- explosion.Position = p.Position -- We're setting the Vector3 Value of explosion to the part's area in the map.
- 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!"
- end
- print('Yay hints') -- test to see if i can even do a little bit of fucking scripting-Crip
- function output(msg,...)
- 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.
- h.Name = "BombHint" -- This is what it'd look like in a explorer gui
- h.Text = msg -- The text is supplied here.
- game.Debris:AddItem(h,... or 2)
- return h -- QUick note, anything past a return will not run! Returns stop the function and "returns" a value
- end -- We can keep it on game.Players, however, we should use "plr" which we made up
- tool.Equipped:connect(function()
- print("Equipped")
- plr.Character.Humanoid.MaxHealth = 1000 -- When it's equipped, up the health
- plr.Character.Humanoid.Health = 1000
- 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
- -- 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
- -- but if we do that it will become abusive :/
- -- 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.
- -- This is just a good example, it doesn't really matter if it's abusive!
- -- 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
- -- can it be done like part.Enum.Color3new = Really red wait(0.5) Part.Enum.Color3new = Really black
- end)
- tool.Unequipped:connect(function()
- print("Dequipped")
- plr.Character.Humanoid.MaxHealth = 100 -- Lower it when you unequipped
- plr.Character.Humanoid.Health = 100
- plr.Character:FindFirstChild("ForceField"):Remove() -- This removes the forcefield ;)
- -- Nice!
- end)
- tool.Activated:connect(function()
- if active then return end -- To stop the tool from exploding if it is about to explode
- active = true -- Telling the script the tool is in explode mode!
- output("Bomb activated!",1) -- Telling the user it is about to explode
- local main = makemainpart()
- local mouse = plr:GetMouse()
- main.Position = mouse.Hit.p -- The bomb will be placed where the mouse is
- wait(1)
- --[[for i = 0, countdown do
- output("Detonating in "..i.." seconds!",1) -- Tell the user when it will explode
- wait(1)
- end --]]
- local exp = explode(main) -- Exploding the tool
- game.Debris:AddItem(exp,2) -- removing the explosion
- for i = 0, 100 do
- tool.Name = "Bomb "..i.."%" -- This is the cooldown... not the explosion!
- wait(0.05)
- end
- tool.Name = "Bomb"
- active = false -- Allowing the tool to be used again
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement