generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: BOOM! Says the button.

Previous Thread :: Next Thread 
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
04 Jan 2012 03:02 PM
I wanted to make an explosion in a random player whenever the button is pressed.
' [---] ' marks the spot where the random player method needs to come.
------------------------------------------------------------------------
function onClicked()
Instance.new("Explosion", game.Workspace. [---])
end
script.Parent.ClickDetector.MouseClick:connect (onClicked)
------------------------------------------------------------------------
Thank you for reading,
help is appreciated
Report Abuse
Thunderx10 is not online. Thunderx10
Joined: 17 Jun 2009
Total Posts: 2316
04 Jan 2012 03:05 PM
function onClicked(player)
e = Instance.new("Explosion")
e.Parent = player.Character.Torso
e.Position = player.Character.Torso.Position --Try this?
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
saiden is not online. saiden
Joined: 19 Aug 2008
Total Posts: 104
04 Jan 2012 03:07 PM
Try defining BlastRadius and BlastPressure for the exlposion.
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
04 Jan 2012 03:07 PM
Wouldn't that make the player explode which clicked the button?
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
04 Jan 2012 03:09 PM
players = game.Players:GetChildren()
random = math.random(1,#players)
local expl = Instance.new("Explosion", game.Workspace)
expl.Position = players[random]




So just to explain it : an explosion is created in a 3d position, not in an object. So the parent has to be ~= nil and the position has to be set ( else it would be created at default position 0,0,0)
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
04 Jan 2012 03:10 PM
Thunderx, that's not random, that's the person who triggered the function.
Saiden, it doesn't matter, the defaults are fair enought.
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
04 Jan 2012 03:11 PM
Wuppi, exactly.
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
04 Jan 2012 03:12 PM
Mind to explain this part? '(1,#players)'
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
04 Jan 2012 03:18 PM
[ Content Deleted ]
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
04 Jan 2012 03:20 PM
So if I would do this: (2,#players)
it would take 2 players?

Ps. Where do I put the lines of FreeToTake?
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
04 Jan 2012 03:22 PM
math.random() lowest - highest, get a random value


so math.random(1,#players)

#players is the amount of players (players = game.Players:GetChildren() sets a table with all players as data).

Then #players is a number, so we can say the lowest random value is 1 (because there has to be at least one player to run the script) and the highest value is #players, since we don't know howmuch players there are.
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
04 Jan 2012 03:22 PM
2,#players would make the first person of the server resistant :)
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
04 Jan 2012 03:23 PM
Replace the body of the function with my lines.


function blahblah()
--mylines
end
connection
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
04 Jan 2012 03:25 PM
FOr some reason the output is QQ'ing, lol

This:
22:18:07 - Workspace.Part.Script:5: bad argument #3 to '?' (Vector3 expected, got userdata)
22:18:07 - Script "Workspace.Part.Script", Line 5
22:18:07 - stack end
22:18:07 - Disconnected event because of exception
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
04 Jan 2012 03:34 PM
Instance.new("Bump", Website.Forums.SH.Thread)
: )
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
05 Jan 2012 10:35 AM
Bawmpercar
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
05 Jan 2012 10:37 AM
players = game.Players:GetChildren()
random = math.random(1,#players)
local expl = Instance.new("Explosion", game.Workspace)
expl.Position = Vector3.new(players[random.Position])

http://www.roblox.com/CFrame-Plugin-item?id=69164738
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
05 Jan 2012 10:38 AM
    layers = game.Players:GetChildren()
    random = math.random(1,#players)
    local expl = Instance.new("Explosion", game.Workspace)
    expl.Position = Vector3.new(players[random.Character.Torso.Position])

http://www.roblox.com/CFrame-Plugin-item?id=69164738
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image