generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: "attempt to connect failed:passed value is not a function"

Previous Thread :: Next Thread 
Bitwyl is not online. 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 is not online. Bitwyl
Joined: 15 Nov 2014
Total Posts: 7276
08 Dec 2016 10:35 PM
b
Report Abuse
vat21s is not online. vat21s
Joined: 07 Jun 2010
Total Posts: 2508
08 Dec 2016 10:39 PM
Why does this script use LocalPlayer?
Report Abuse
Bitwyl is not online. Bitwyl
Joined: 15 Nov 2014
Total Posts: 7276
08 Dec 2016 10:42 PM
yolo

help or naw
Report Abuse
vat21s is not online. 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 is not online. 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 is not online. 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
Julian_Orteil is not online. Julian_Orteil
Joined: 14 Aug 2012
Total Posts: 968
08 Dec 2016 10:53 PM
Is this in a LocalScript or ServerScript?
Report Abuse
Bitwyl is not online. 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
NumenoreanDude is not online. NumenoreanDude
Joined: 28 Jun 2016
Total Posts: 85
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
NumenoreanDude is not online. NumenoreanDude
Joined: 28 Jun 2016
Total Posts: 85
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image