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: Script not working

Previous Thread :: Next Thread 
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 03:16 PM
Why does this script give me an error in Output saying "Humanoid is not a valid member of Part"?

local model = script.Parent.Parent
local screen = model.screen
local add = model.Add

function addName(hit)
if hit.Humanoid ~= nil then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Namee = hit.Name
end
end

add.Touched:connect(addName)


Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
27 Jul 2016 03:18 PM
function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Namee = hit.Parent.Name
end
end


( ͡• ◡ ͡•) -=[ RAP: 346,681 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•)
Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 03:29 PM
Okay, so this works, but it adds many times, I know there's a way I can make it like only do it once but I don't know how, please help.

local model = script.Parent.Parent
local screen = model.screen
local add = model.Add
local remove = model.Remove

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Name = hit.Parent.Name
end
end

function removeName(hit)
--stuff
end

add.Touched:connect(addName)
remove.Touched:connect(removeName)


Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
27 Jul 2016 03:40 PM
You need a debounce.

local model = script.Parent.Parent
local screen = model.screen
local add = model.Add
local remove = model.Remove
local debounce = false

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil and not debounce then
debounce = true
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Name = hit.Parent.Name
debounce = false
end
end

function removeName(hit)
--stuff
end

add.Touched:connect(addName)
remove.Touched:connect(removeName)


( ͡• ◡ ͡•) -=[ RAP: 347,122 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•)
Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 03:46 PM
Doesn't work, still spams me with values, nothing in output.


Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
27 Jul 2016 04:29 PM
local model = script.Parent.Parent
local screen = model.screen
local add = model.Add
local remove = model.Remove

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- Add an "and not" here to see if the player doesn't have a "CFrameValue".
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Name = hit.Parent.Name
end
end

function removeName(hit)
--stuff
end

add.Touched:connect(addName)
remove.Touched:connect(removeName)


( ͡• ◡ ͡•) -=[ RAP: 348,476 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•)
Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 07:12 PM
I'm very confused what you mean "Add an and not to see if the player doesn't have a "CFrameValue"


Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 07:28 PM
cough


Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 07:43 PM
cough cough


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
27 Jul 2016 07:47 PM
"if hit.Humanoid ~= nil"

Hit will return the part hit.

None of the parts in any character has a humanoid inside it. it only has a humanoid inside its parent

hit.Parent:FindFirstChild("Humanoid") will see if the hit object has a humanoid in its parent, if not will return nil
Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 07:58 PM
Durst already corrected that, what doesn't work is;

local model = script.Parent.Parent
local screen = model.screen
local add = model.Add
local remove = model.Remove

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- Add an "and not" here to see if the player doesn't have a "CFrameValue".
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Name = hit.Parent.Name
end
end

function removeName(hit)
--stuff
end

add.Touched:connect(addName)
remove.Touched:connect(removeName)


Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
27 Jul 2016 08:49 PM
cough cough cough


Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
28 Jul 2016 12:07 AM
cough cough cough cough
Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
28 Jul 2016 12:38 AM
cough cough cough cough cough
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
28 Jul 2016 12:41 AM

--here try this:
local model = script.Parent.Parent
local screen = model.screen
local add = model.Add

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.ClassName == "Humanoid" then
if hit.Humanoid ~= nil then
--local n = Instance.new("CFrameValue", add.PlayersInLine)
--n.Namee = hit.Name
end end end
end

add.Touched:connect(addName)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
28 Jul 2016 12:42 AM
wait "2"
--here try this:
local model = script.Parent.Parent
local screen = model.screen
local add = model.Add

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.ClassName == "Humanoid" then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Namee = hit.Name
end end
end

add.Touched:connect(addName)
Report Abuse
iLordOfAviation is not online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
28 Jul 2016 12:47 AM
I'm not real sure what you think adding that would do, but I think I figured out how I can do it, I'm on mobile and don't want to forget so don't mind my note to self; STOP BEING AN IDIOT, CHECK IF THEY ALREADY HAVE A VALUE
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
28 Jul 2016 12:50 AM
k
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
28 Jul 2016 12:51 AM
--here try this:
local model = script.Parent.Parent
local screen = model.screen
local add = model.Add

function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") and not add.PlayerInLine:FindFirstChild(add) then
if hit.Parent.Humanoid.ClassName == "Humanoid" then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Namee = hit.Name
end end
end

add.Touched:connect(addName)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
28 Jul 2016 12:55 AM

--[[try this:]]wait "2"
local model = script.Parent.Parent
local screen = model.screen
local add = model.Add
function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") and not add.PlayerInLine:FindFirstChild(hit.Parent.Name) then
if hit.Parent.Humanoid.ClassName == "Humanoid" then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Namee = hit.Parent.Name
end end end
add.Touched:connect(addName)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
28 Jul 2016 12:55 AM

--[[try this:]]wait "2"
local model = script.Parent.Parent
local screen = model.screen
local add = model.Add
function addName(hit)
if hit.Parent:FindFirstChild("Humanoid") and not add.PlayerInLine:FindFirstChild(hit.Parent.Name) then
if hit.Parent.Humanoid.ClassName == "Humanoid" then
local n = Instance.new("CFrameValue", add.PlayersInLine)
n.Name = hit.Parent.Name
end end end
add.Touched:connect(addName)
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