|
| 28 Jun 2012 09:55 PM |
I've been trying to figure out the function to make the tool's function take effect on clicked, bur I haven't yet. Each time, it says "Line 54, attempting to index global 'mouse' a nil value". Could you tell me how I can correct this?
function onButton1Down(mouse) local player = script.Parent.Parent local h = script.Parent:findFirstChild("Humanoid") local wish = Instance.new("Part") local m = script.Parent.Mesh wish.Size = 2,2,2 wish.BrickColor = BrickColor.new("Teal") wish.Name = "WishProjectile" wish.Locked = true wish.FormFactor = 0 wish.Shape = 0 wish.TopSurface = 0 wish.BottomSurface = 0 local wish2 = wish:clone() local wish3 = Instance.new("Part") wish3.Size = 1,1,1 wish3.BrickColor = BrickColor.new("Teal") wish3.Name = "WishProjectile2" wish3.Locked = true wish3.FormFactor = 0 wish3.Shape = 0 wish3.TopSurface = 0 wish3.BottomSurface = 0 wish3.Mesh = m wish3.Anchored = true if player ~= nil then wish.Parent = game.Workspace wish.Position = player.Torso.Position + Vector3.new(0,1,0) wish.Velocity = Vector3.new(0,100,0) wait(0.1) repeat wait(0.05) wish.Transparency = wish.Transparency + 0.05 until wish.Transparency >= 1 wish:remove() wait(5) wish2.Parent = game.Workspace wish2.Position = player.Torso.Position + Vector3.new(0,30,0) wait(0.7) wish3.Parent = game.Workspace wish3.Position = wish2.Position wish2:remove() h.Health = h.MaxHealth wait(0.1) repeat wait(0.1) wish3.Size = wish3.Size + Vector3.new(1,0,1) wish3.Transparency = wish3.Transparency + 0.05 until wish3.Transparency >= 1 wish3:remove() end end
mouse.Button1Down:connect(onButton1Down) |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 28 Jun 2012 09:57 PM |
Connection line "mouse.Button1Down:connect(onButton1Down)" should be MouseButton1Down:connect(onButton1Down) |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2012 09:58 PM |
| Thank you, I'll give it a shot. |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 28 Jun 2012 09:59 PM |
| Or does that apply for Guis only? O.e |
|
|
| Report Abuse |
|
|
Archived
|
  |
| Joined: 25 Jan 2012 |
| Total Posts: 40 |
|
|
| 28 Jun 2012 10:01 PM |
Scripting can be useful. But it is also used as a terrible ROBLOX crime. |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 28 Jun 2012 10:06 PM |
| I checked and it won't work. Is this a tool or Hopperbin? |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2012 10:09 PM |
| Oh, HopperBin. Sorry I didn't mention that. Anyway, it still comes up with MouseButton1Down as the nil value. |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 28 Jun 2012 10:12 PM |
local bin = script.Parent local function hSelect(m) local function bdown() local player = script.Parent.Parent local h = script.Parent:findFirstChild("Humanoid") local wish = Instance.new("Part") local m = script.Parent.Mesh wish.Size = 2,2,2 wish.BrickColor = BrickColor.new("Teal") wish.Name = "WishProjectile" wish.Locked = true wish.FormFactor = 0 wish.Shape = 0 wish.TopSurface = 0 wish.BottomSurface = 0 local wish2 = wish:clone() local wish3 = Instance.new("Part") wish3.Size = 1,1,1 wish3.BrickColor = BrickColor.new("Teal") wish3.Name = "WishProjectile2" wish3.Locked = true wish3.FormFactor = 0 wish3.Shape = 0 wish3.TopSurface = 0 wish3.BottomSurface = 0 wish3.Mesh = m wish3.Anchored = true if player ~= nil then wish.Parent = game.Workspace wish.Position = player.Torso.Position + Vector3.new(0,1,0) wish.Velocity = Vector3.new(0,100,0) wait(0.1) repeat wait(0.05) wish.Transparency = wish.Transparency + 0.05 until wish.Transparency >= 1 wish:remove() wait(5) wish2.Parent = game.Workspace wish2.Position = player.Torso.Position + Vector3.new(0,30,0) wait(0.7) wish3.Parent = game.Workspace wish3.Position = wish2.Position wish2:remove() h.Health = h.MaxHealth wait(0.1) repeat wait(0.1) wish3.Size = wish3.Size + Vector3.new(1,0,1) wish3.Transparency = wish3.Transparency + 0.05 until wish3.Transparency >= 1 wish3:remove() end end m.Button1Down:connect(bdown) end bin.Selected:connect(hSelect)
That should work. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2012 10:14 PM |
| I think I understand it... If this works I'll use it from now on. Testing... |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 28 Jun 2012 10:15 PM |
| Yea for hopperbins you have to check if they are selected. Tools use .Equipped |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2012 10:43 PM |
Alright, the HopperBin was causing me problems, so I changed it to a basic Tool using this script, which STILL doesn't work. Once again, it says that MouseButton1Down is a nil value.
function onButton1Down(mouse) local player = script.Parent.Parent local h = player.Humanoid local t = script.Torso local wish = Instance.new("Part") local m = script.Parent.Mesh wish.Size = 2,2,2 wish.BrickColor = BrickColor.new("Teal") wish.Name = "WishProjectile" wish.Locked = true wish.FormFactor = 0 wish.Shape = 0 wish.TopSurface = 0 wish.BottomSurface = 0 local wish2 = wish:clone() local wish3 = Instance.new("Part") wish3.Size = 1,1,1 wish3.BrickColor = BrickColor.new("Teal") wish3.Name = "WishProjectile2" wish3.Locked = true wish3.FormFactor = 0 wish3.Shape = 0 wish3.TopSurface = 0 wish3.BottomSurface = 0 wish3.Mesh = m wish3.Anchored = true if player ~= nil then wish.Parent = game.Workspace wish.Position = player.Torso.Position + Vector3.new(0,1,0) wish.Velocity = Vector3.new(0,100,0) wait(0.1) repeat wait(0.05) wish.Transparency = wish.Transparency + 0.05 until wish.Transparency >= 1 wish:remove() wait(5) wish2.Parent = game.Workspace wish2.Position = player.Torso.Position + Vector3.new(0,30,0) wait(0.7) wish3.Parent = game.Workspace wish3.Position = wish2.Position wish2:remove() h.Health = h.MaxHealth wait(0.1) repeat wait(0.1) wish3.Size = wish3.Size + Vector3.new(1,0,1) wish3.Transparency = wish3.Transparency + 0.05 until wish3.Transparency >= 1 wish3:remove() script.Disabled = true wait(30) script.Disabled = false end end MouseButton1Down:connect(onButton1Down) |
|
|
| Report Abuse |
|
|
| |
|