|
| 07 Feb 2013 10:57 PM |
p = game.Players.LocalPlayer local Tool = script.Parentfunction onButton1Down(mouse)
if script.Parent.Disable.Value ~= true then script.Parent.Disable.Value = true wait (1.5) local m = math.random(1,3) if m == 1 then game.Lighting["Iron Sword"]:Clone().Parent = p.Backpack end if m == 2 then game.Lighting["Iron Dagger"]:Clone().Parent = p.Backpack end if m == 3 then game.Lighting["Iron Spear"]:Clone().Parent = p.Backpack end end script.Parent:Remove()endfunction onEquippedLocal(mouse) if mouse == nil then print("Mouse not found") return end mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
Tool.Equipped:connect(onEquippedLocal) |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 10:59 PM |
Is it in a local script?
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 07 Feb 2013 11:00 PM |
wait() -- on the first line, don't ask questions, just do it.
local Tool = script.Parent -- these were touching function onButton1Down(mouse) |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:01 PM |
"local Tool = script.Parent -- these were touching function onButton1Down(mouse)" I think that's just because he copied it weirdly, it occurred many times throughout the script.
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:04 PM |
"if m == 1 then game.Lighting["Iron Sword"]:Clone().Parent = p.Backpack end if m == 2 then game.Lighting["Iron Dagger"]:Clone().Parent = p.Backpack end if m == 3 then game.Lighting["Iron Spear"]:Clone().Parent = p.Backpack end"
Should be:
if m == 1 then game.Lighting["Iron Sword"]:Clone().Parent = p.Backpack elseif m == 2 then game.Lighting["Iron Dagger"]:Clone().Parent = p.Backpack elseif m == 3 then game.Lighting["Iron Spear"]:Clone().Parent = p.Backpack else print "Unexpected error." end
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:04 PM |
--[[ I coulden't really find the error, but I did clean your script up some and remove some un-needed stuff. Also, it might not work because you put it in a local script, try using a script.
]]
p = game.Players.LocalPlayer --Not sure if this will work in a tool without local local Tool = script.Parent
function onButton1Down(mouse) --
if Tool.Disable.Value == false then -- Tool.Disable.Value = true wait (1.5) local m = math.random(1,3)
if m == 1 then -- game.Lighting["Iron Sword"]:Clone().Parent = p.Backpack end ---
if m == 2 then -- game.Lighting["Iron Dagger"]:Clone().Parent = p.Backpack end ---
if m == 3 then -- game.Lighting["Iron Spear"]:Clone().Parent = p.Backpack end ---
end ---
script.Parent:Remove() end --
function onEquippedLocal(mouse) mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
Tool.Equipped:connect(onEquippedLocal) |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:05 PM |
"Also, it might not work because you put it in a local script, try using a script." >p = game.Players.LocalPlayer
...
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:06 PM |
Last time I checked, game.Players.LocalPlayer requires a localized script and will only work in solo. |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:07 PM |
| Correction for myself - Will only work in solo if the script is not localized |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 07 Feb 2013 11:07 PM |
All he needs to do is use my solution. :p All LocalScripts need wait() at the top to work properly in online mode. |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2013 11:18 PM |
| Thanks guys. I'll try these out tomorrow, but it's really late and I got to get to sleep. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 02:05 PM |
Nope, they didn't work. I tried changing it from a LocalScript to a regular Script and edited a line, but it only works in solo, too. -------------------
local Tool = script.Parent
function onButton1Down(mouse) if script.Parent.Disable.Value ~= true then script.Parent.Disable.Value = true wait (1.5) p = game.Players:GetPlayerFromCharacter(Tool.Parent) local m = math.random(1,3) if m == 1 then game.Lighting["Iron Sword"]:Clone().Parent = p.Backpack end if m == 2 then game.Lighting["Iron Dagger"]:Clone().Parent = p.Backpack end if m == 3 then game.Lighting["Iron Spear"]:Clone().Parent = p.Backpack end end script.Parent:Remove() end
function onEquippedLocal(mouse) if mouse == nil then print("Mouse not found") return end mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
Tool.Equipped:connect(onEquippedLocal) |
|
|
| Report Abuse |
|
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 10 Feb 2013 12:01 PM |
I told you how to fix it. Put it back the way it was, and add wait() to the first line..
wait() -- Your LocalScript code here. |
|
|
| Report Abuse |
|
|
| |
|