xPoloBear
|
  |
| Joined: 10 Oct 2011 |
| Total Posts: 202 |
|
|
| 10 Nov 2013 03:31 PM |
I scripted this, so when you shoot a player, his humanoid.Health takes 10 out.
My Script:
player = game.Players.LocalPlayer mouse = player:GetMouse()
enabled = true function onButton1Down(mouse) if not enabled then return end enabled = false mouse.Icon = "rbxasset://textures\\GunWaitCursor.png" local h = mouse.Target[mouse.Name].Parent:findFirstChild("Humanoid") if (mouse.Target ~= nil) and (h ~= nil) then h.Health = h.Health - 25 end wait(.2) mouse.Icon = "rbxasset://textures\\GunCursor.png" enabled = true
end
function onEquipped(mouse) x = script.Parent.Handle.Equip x:Play() mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
script.Parent.Equipped:connect(onEquipped)
Output Error:
16:30:03.257 - Instance is not a valid member of Part 16:30:03.259 - Script 'Players.xPoloBear.Backpack.Flintlock.Local Gui', Line 9 - global onButton1Down 16:30:03.265 - Script 'Players.xPoloBear.Backpack.Flintlock.Local Gui', Line 23 16:30:03.266 - stack end
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2013 03:44 PM |
| You can't set the mouse Icon using GetMouse I don't think... |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 10 Nov 2013 03:45 PM |
local h = mouse.Target[mouse.Name].Parent:findFirstChild("Humanoid")
This should be local h = mouse.Target.Parent:findFirstChild("Humanoid")
I also recommend putting, before this line, if not mouse.Target then wait(.1) enabled = true return end |
|
|
| Report Abuse |
|
|
xPoloBear
|
  |
| Joined: 10 Oct 2011 |
| Total Posts: 202 |
|
|
| 10 Nov 2013 03:55 PM |
It works But now when i shoot in to sky, i get this
16:54:51.399 - Players.xPoloBear.Backpack.Flintlock.Local Gui:11: attempt to index field 'Target' (a nil value) 16:54:51.400 - Script 'Players.xPoloBear.Backpack.Flintlock.Local Gui', Line 11 - global onButton1Down 16:54:51.403 - Script 'Players.xPoloBear.Backpack.Flintlock.Local Gui', Line 30 16:54:51.406 - stack end |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
xPoloBear
|
  |
| Joined: 10 Oct 2011 |
| Total Posts: 202 |
|
|
| 10 Nov 2013 04:00 PM |
player = game.Players.LocalPlayer mouse = player:GetMouse() f = script.Parent.Handle.Shot
enabled = true function onButton1Down(mouse) if not enabled then return end enabled = false mouse.Icon = "rbxasset://textures\\GunWaitCursor.png" f:Play() local h = mouse.Target.Parent:findFirstChild("Humanoid") if (mouse.Target ~= nil) and (h ~= nil) then h.Health = h.Health - 25 else if (mouse.Target ~= nil) and not (h ~= nil) then print("Not Found") end end wait(5) mouse.Icon = "rbxasset://textures\\GunCursor.png" enabled = true
end
function onEquipped(mouse) x = script.Parent.Handle.Equip x:Play() mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
script.Parent.Equipped:connect(onEquipped)
|
|
|
| Report Abuse |
|
|
xPoloBear
|
  |
| Joined: 10 Oct 2011 |
| Total Posts: 202 |
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 10 Nov 2013 09:29 PM |
My earlier post
"local h = mouse.Target[mouse.Name].Parent:findFirstChild("Humanoid")
This should be local h = mouse.Target.Parent:findFirstChild("Humanoid")
I also recommend putting, before this line, if not mouse.Target then wait(.1) enabled = true return end"
Clearly you did not do the last line that I recommended This would've prevented that.
So put if not mouse.Target then wait(.1) enabled = true return end Before local h = mouse.Target.Parent:findFirstChild("Humanoid") |
|
|
| Report Abuse |
|
|