Bitwyl
|
  |
| Joined: 15 Nov 2014 |
| Total Posts: 7276 |
|
|
| 08 Dec 2016 10:33 PM |
g.Touched:connect(function() local player = game:GetService("Players").LocalPlayer local humanoid = player.Character.Humanoid if g.Touched then print'rip' if nil then humanoid.Health = 100 else humanoid.Health = 0 end end end) g.Touched:connect()
also.."attempt to call a nil value"
|
|
|
| Report Abuse |
|
|
Bitwyl
|
  |
| Joined: 15 Nov 2014 |
| Total Posts: 7276 |
|
| |
|
vat21s
|
  |
| Joined: 07 Jun 2010 |
| Total Posts: 2508 |
|
|
| 08 Dec 2016 10:39 PM |
| Why does this script use LocalPlayer? |
|
|
| Report Abuse |
|
|
Bitwyl
|
  |
| Joined: 15 Nov 2014 |
| Total Posts: 7276 |
|
| |
|
vat21s
|
  |
| Joined: 07 Jun 2010 |
| Total Posts: 2508 |
|
|
| 08 Dec 2016 10:42 PM |
replace game.Workspace.Part with whatever part you want alternatively, you could replace it with script.Parent and put this script in any part you want to deal damage
game.Workspace.Part.Touched:connect(function(hit) if hit:FindFirstChild("Humanoid") then hit.Humanoid:TakeDamage(100) end end)
|
|
|
| Report Abuse |
|
|
Bitwyl
|
  |
| Joined: 15 Nov 2014 |
| Total Posts: 7276 |
|
|
| 08 Dec 2016 10:47 PM |
still gives me the error in the title. no longer have nil problems though.
the thing is, g is the part in workspace, but it's created with a button, and disappears after a short time, which may be the reason it's causing error. |
|
|
| Report Abuse |
|
|
vat21s
|
  |
| Joined: 07 Jun 2010 |
| Total Posts: 2508 |
|
|
| 08 Dec 2016 10:50 PM |
Put this script in the script that makes the part and clone the script to the part when it's created.
script.Parent.Touched:connect(function(hit) if hit:FindFirstChild("Humanoid") then hit.Humanoid:TakeDamage(100) end end) |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2016 10:53 PM |
| Is this in a LocalScript or ServerScript? |
|
|
| Report Abuse |
|
|
Bitwyl
|
  |
| Joined: 15 Nov 2014 |
| Total Posts: 7276 |
|
|
| 08 Dec 2016 10:57 PM |
@Julian local
@other that's literally the same thing you gave me before.. |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2016 11:23 PM |
| Um, you code "g.Touched:connect(function()" but later also call "g.Touched:connect()". This is making you call the nil value and failing at calling a value because "connect()" should have a function in the brackets. |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2016 11:25 PM |
| I think the "attempt to call a nil value" may also be because you have "if nil then", which doesn't declare what being nil you are looking for. An example fix would be "if humanoid ~= nil then", but I don't know the full context. |
|
|
| Report Abuse |
|
|