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 |
|
|
|
| 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
|
  |
| Joined: 19 Aug 2008 |
| Total Posts: 104 |
|
|
| 04 Jan 2012 03:07 PM |
| Try defining BlastRadius and BlastPressure for the exlposion. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
wuppii
|
  |
| Joined: 20 Feb 2010 |
| Total Posts: 1625 |
|
|
| 04 Jan 2012 03:12 PM |
Mind to explain this part? '(1,#players)'
|
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 04 Jan 2012 03:22 PM |
| 2,#players would make the first person of the server resistant :) |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2012 03:23 PM |
Replace the body of the function with my lines.
function blahblah() --mylines end connection |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 20 Feb 2010 |
| Total Posts: 1625 |
|
|
| 04 Jan 2012 03:34 PM |
Instance.new("Bump", Website.Forums.SH.Thread) : ) |
|
|
| Report Abuse |
|
|
wuppii
|
  |
| Joined: 20 Feb 2010 |
| Total Posts: 1625 |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|