|
| 30 Jul 2014 10:31 PM |
Using getmouse, how do I refer to the position of the mouse? This is what I tried.
script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() if m.Target then local kaboomage = Instance.new("Explosion") kaboomage.Parent = Workspace kaboomage.Position = m.Target end end) end) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:34 PM |
| http://wiki.roblox.com/index.php?title=Hit_(Property) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:36 PM |
You should use ray casting.
script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() if m.Target then local kaboomage = Instance.new("Explosion") kaboomage.Parent = Workspace kaboomage.Position = m.Hit.p end end) end) |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 30 Jul 2014 10:36 PM |
mouse = game.Players.LocalPlayer:GetMouse() --local script; gets mouse
pos = mouse.hit.p --gets the position |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:36 PM |
Thanks kind-of. Told me of a property I didn't know about, not how to use it.
I tried this.
script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() if m.Target then local kaboomage = Instance.new("Explosion") kaboomage.Parent = Workspace kaboomage.Position = m.Hit end end) end) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:38 PM |
Oh, I see, thanks guys.
I assume .p means .Position?
Also, where can I learn about raycasting? I have no idea what it is or how to use it. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:40 PM |
http://wiki.roblox.com/index.php?title=Raycasting
have you used the wiki before? if not, AMAZING place to learn all things scripting/building :) wiki.roblox.com |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:51 PM |
While were on the subject of this script, this was my attempt at making infinite explosions until the user let go of their mouse.
It didn't work, what should I have done?
script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() if m.Target then repeat wait() local kaboomage = Instance.new("Explosion") kaboomage.DestroyJointRadiusPercent = .2 kaboomage.BlastRadius = 15 kaboomage.Parent = Workspace kaboomage.Position = m.Hit.p kaboomage.BlastPressure = 999999 until m.Button1Up end end) end) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 10:54 PM |
local Button = false; script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() Button = true; if m.Target then repeat wait() local kaboomage = Instance.new("Explosion") kaboomage.DestroyJointRadiusPercent = .2 kaboomage.BlastRadius = 15 kaboomage.Parent = Workspace kaboomage.Position = m.Hit.p kaboomage.BlastPressure = 999999 until not Button end end) end) Mouse.Button1Up:connect(function() Button = false; end) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 11:03 PM |
That worked to a very small extent unfortunately.
After removing the habitual semicolons and changing "Mouse" to "m", it works in a glitchy way in studio, not at all in game.
This is the error I get.
Players.Player1.Backpack.Explode (Admin).Script:16: attempt to index global 'm' (a nil value)
local Button = false script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() Button = true if m.Target then repeat wait() local kaboomage = Instance.new("Explosion") kaboomage.BlastRadius = 15 kaboomage.Parent = Workspace kaboomage.Position = m.Hit.p until not Button end end) end) m.Button1Up:connect(function() Button = false end) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 11:18 PM |
Woops. forgot to put the button 1 up event inside the equipped event
local Button = false script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() Button = true if m.Target then repeat wait() local kaboomage = Instance.new("Explosion") kaboomage.BlastRadius = 15 kaboomage.Parent = Workspace kaboomage.Position = m.Hit.p until not Button end end) m.Button1Up:connect(function() Button = false end) end) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 11:20 PM |
I noticed that too and fixed it, but it only works in studios with no errors. In game there is no explosion.
local Button = false script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() m.Button1Up:connect(function() Button = false end) Button = true if m.Target then repeat wait() local kaboomage = Instance.new("Explosion") kaboomage.BlastRadius = 15 kaboomage.Parent = Workspace kaboomage.Position = m.Hit.p until not Button end end) end)
|
|
|
| Report Abuse |
|
|