SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 05:53 PM |
I making a GUI button that spawns an explosion in the players torso, but it doesn't work because I can't get the players torso. Can anyone help?
Here's the script.
function onclick() local pos = (This is so the position of the bomb is that of the torso, but I cant get the torso) local bomb = Instance.new("Explosion", ???) bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = pos end script.Parent.MouseButton1Click:connect(onclick)
|
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 05:55 PM |
player's Character's torso
should be indented script.Parent.MouseButton1Click:connect(function(player) player.CharacterAdded:wait() local pos = (This is so the position of the bomb is that of the torso, but I cant get the torso) local bomb = Instance.new("Explosion", player.Character:WaitForChild('Torso')) bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = pos end) |
|
|
| Report Abuse |
|
|
Stormify
|
  |
| Joined: 27 Jan 2012 |
| Total Posts: 378 |
|
|
| 21 Feb 2015 05:59 PM |
this is a revamped better one
script.Parent.MouseButton1Click:connect(function(playerwhoclicked) bomb = Instance.new("Explosion") bomb.Parent = playerwhoclicked.Character.Torso bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 end)
don't know if it will work but there it is
mk |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 05:59 PM |
| I tried that, it gives me the error 'attempt to index local 'player' (a nil value)' |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 06:01 PM |
| Storm that won't work you have to set the position of an explosion. |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 06:01 PM |
Holy crap I'm insane
I thought it was a click detector and used the gui event stil lol
1 sec |
|
|
| Report Abuse |
|
|
Stormify
|
  |
| Joined: 27 Jan 2012 |
| Total Posts: 378 |
|
|
| 21 Feb 2015 06:02 PM |
oh alright i didn't check
mk |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:02 PM |
| Same error for yours stormily, except it's attempt to index local 'playerwhoclicked' a nil value |
|
|
| Report Abuse |
|
|
Stormify
|
  |
| Joined: 27 Jan 2012 |
| Total Posts: 378 |
|
|
| 21 Feb 2015 06:04 PM |
script.Parent.MouseButton1Click:connect(function(playerwhoclicked) bomb = Instance.new("Explosion") pos = playerwhoclicked.Character.Torso.CFrame bomb.Parent = playerwhoclicked.Character.Torso bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = pos
end)
mk |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
| |
|
devCure
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 125 |
|
| |
|
devCure
|
  |
| Joined: 30 Jun 2012 |
| Total Posts: 125 |
|
|
| 21 Feb 2015 06:06 PM |
| this in a localscript or normal script? |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 06:06 PM |
-- LocalScript in the GUI:
local player = game.Players.LocalPlayer local element = script.Parent local torso = player.Character:WaitForChild('Torso')
local debounce = true element.MouseButton1Click:connect(function() if not debounce then return end debounce = false game.ReplicatedStorage.RemoteEvents:FireServer(torso) debounce = true end)
-- Script in ServerScriptService.
local explode = Instance.new("RemoteEvent") explode.Name = "Explode" explode.Parent = game.ReplicatedStorage.RemoteEvents --make a folder for it. explode.OnServerEvent:connect(function(player, part) local bomb = Instance.new("Explosion", workspace) bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = part.Position end)
didn't test of course |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:06 PM |
| Normal right now, I tried both in a Local one and it didn't work. |
|
|
| Report Abuse |
|
|
ChoongJae
|
  |
| Joined: 10 Oct 2009 |
| Total Posts: 670 |
|
|
| 21 Feb 2015 06:08 PM |
put this in a localscript under the button
local plr=game.Players.LocalPlayer
function onclick() if plr.Character and plr.Character.Torso then local pos = plr.Character.Torso.Position local bomb = Instance.new("Explosion", ???) bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = Vector3.new(pos) end end
script.Parent.MouseButton1Click:connect(onclick) |
|
|
| Report Abuse |
|
|
| |
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:11 PM |
| Neither of the new ones work. Chiefs gives me an error message, and Choong's doesn't do anything |
|
|
| Report Abuse |
|
|
| |
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:13 PM |
| RemoteEvents is not a valid member of ReplicatedStorage |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 06:14 PM |
*facedesk*
im going to let you read the code. |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:15 PM |
Wait, wait wait hold up Choong's works, but it was written wrong
This was the original
local plr=game.Players.LocalPlayer
function onclick()
local pos = plr.Character.Torso.Position local bomb = Instance.new("Explosion", workspace) bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = ------>Vector3.new(pos) <---- end
script.Parent.MouseButton1Click:connect(onclick)
I changed it to local plr=game.Players.LocalPlayer
function onclick()
local pos = plr.Character.Torso.Position local bomb = Instance.new("Explosion", workspace) bomb.BlastPressure = 1500000 bomb.BlastRadius = 10 bomb.Position = ---->pos<----- end
script.Parent.MouseButton1Click:connect(onclick)
And it works cuz when there is a variable, you don't need to use Vector3.new |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 06:17 PM |
Trust me, you want to use my code.
You have to put a RemoteEvents folder in ReplicatedStorage of course. |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:18 PM |
| The one I'm using works perfectly fine, I don't see the need to change it. |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 06:18 PM |
"The one I'm using works perfectly fine, I don't see the need to change it."
that's because you have absolutely no clue what you're doing |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 21 Feb 2015 06:20 PM |
| Dude, it works I tried it like 10 times. Just calm down. |
|
|
| Report Abuse |
|
|