GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 11:54 AM |
I'm trying to make a script that will drop a tool (Bomb) when you left click. I've asked for help with the left click thing and no ones helped me. Please help me with the script:
tool = Can Bomb High Yield--Do I need to put the tools name here?
function Drop() --What comes here??? Please tell me. handle:Destroy() tool.Parent = workspace end mouse.Button1Down:connect(Drop)
What do I do to make the handle get destroyed when you left click???
|
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 12:00 PM |
Or would it need to be in a Local GUI script thingy? and look like this?
tool = Can Bomb High Yield--Do I need to put the tools name here?
enabled = true
function onButton1Down(mouse)
handle:Destroy()
tool.Parent = workspace
if not enabled then return end
enabled = false mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
wait(7) mouse.Icon = "rbxasset://textures\\GunCursor.png" enabled = true
end
function onEquippedLocal(mouse)
if mouse == nil then print("Mouse not found") return end
mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
Tool.Equipped:connect(onEquippedLocal)
(/\ Tried that and nothing happens.) |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 12:02 PM |
You weren't far off. tool = tools location --You'll have to figure out the path to the tool handle = tool.handle function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop) |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 12:06 PM |
| The tools location is Workspace, right? Or is it Player?? (I'm still new to scripting.) |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 12:08 PM |
| No problem. The tool is in the player, and the best way to identify the player is use a local script and get the player that way. |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 12:11 PM |
So, the finished script would look like this?
tool = tools.Player.Backpack --<< Is that right? handle = tool.handle function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop) |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
| |
|
|
| 03 Aug 2012 12:59 PM |
The best way would be using script.Parent, which is usually the tool. You know how to use script.Parent, right?
If not I'll explain.
--BrandonFireflower, LuaLearners Writer and president of the Exodus Task Force. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:20 PM |
tool = script.Parent --<< This is correct handle = tool.handle function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop) |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:21 PM |
ops, one more error:
tool = script.Parent handle = tool.Handle function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop) |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 01:22 PM |
@Brand, I'm not 100% for sure what it is.
@Cheat, thanks.
So i just put the script into a local GUI script and it'll work? Or does it still need something? |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:24 PM |
| only put it directly into the tool |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 01:26 PM |
Like this: http://www.roblox.com/Can-Bomb-High-Yield-item?id=88845168
|
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 01:28 PM |
Wait.. Just tested it.. -_- nothing happens again :/
Am I missing something or what? |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:29 PM |
| yes you have did something wrong. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:29 PM |
| you have to use the event Equipped to get the mouse |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:31 PM |
read on this site to find out how it works: http://wiki.roblox.com/index.php/Equipped |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 01:31 PM |
Oh. fixed version I think:
tool = script.Parent handle = tool.Handle
function onEquippedLocal(mouse)
function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop)
if mouse == nil then print("Mouse not found") return end
mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
Tool.Equipped:connect(onEquippedLocal)
function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop)
|
|
|
| Report Abuse |
|
|
|
| 03 Aug 2012 01:33 PM |
this is more correct:
tool = script.Parent handle = tool.Handle
function onEquippedLocal(mouse)
function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop)
if mouse == nil then print("Mouse not found") return end
mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
Tool.Equipped:connect(onEquippedLocal) |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 01:34 PM |
@ cheat didn't see that till now.
okay so, in this:
local function onEquipped(mouse) mouse.KeyDown:connect(onKeyDown) mouse.Button1Down.connect(function() onButton1Down(mouse) end) end tool.Equipped:connect(onEquipped)
where do I put my function at? please put a " --here " in where my function goes. |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
| |
|
doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
|
| 03 Aug 2012 01:38 PM |
| If you want it to come back you need to clone it. |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 03 Aug 2012 01:38 PM |
Script didn't work.
Lemme try this:
tool = script.Parent handle = tool.Handle
local function onEquipped(mouse) function Drop() handle:Destroy() tool.Parent = game.Workspace end mouse.Button1Down:connect(Drop)
mouse.Button1Down.connect(function() onButton1Down(mouse) end) end tool.Equipped:connect(onEquipped) |
|
|
| Report Abuse |
|
|