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 » Scripting Helpers
Home Search
 

What's wrong with this?

Previous Thread :: Next Thread 
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
15 Aug 2013 01:18 PM
Basically, I'm trying to find out if the ray has hit a Player. The output is telling me "Parent is not a valid member"

ray = Ray.new(veh.Gun.Shooter.Position, (veh.Gun.Shooter.CFrame.lookVector).unit * 300)
part,hit = Workspace:FindPartOnRay(ray)

humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(30)
end
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
15 Aug 2013 01:19 PM
The output is responding to this line btw. "humanoid = hit.Parent:findFirstChild("Humanoid")"
Report Abuse
funnymouse7 is not online. funnymouse7
Joined: 17 Mar 2011
Total Posts: 1741
15 Aug 2013 01:34 PM
ray = Ray.new(veh.Gun.Shooter.Position, (veh.Gun.Shooter.CFrame.lookVector).unit * 300)
part,hit = Workspace:FindPartOnRay(ray)

if hit.Parent.Humanoid then
hit.Parent.Humanoid:TakeDamage(30)
end

try that, not sure if it'll work though
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
15 Aug 2013 01:36 PM
That won't change anything.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
15 Aug 2013 01:44 PM
ray = Ray.new(veh.Gun.Shooter.Position, (veh.Gun.Shooter.CFrame.lookVector).unit * 300)
part,hit = Workspace:FindPartOnRay(ray)


if part and part.Parent:findFirstChild("Humanoid") then
local humanoid = hit.Parent:findFirstChild("Humanoid")
humanoid:TakeDamage(30)
end
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
15 Aug 2013 01:49 PM
That's got it working so that it works. But now when it hits a person it returns that error and the player doesn't take damage.
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
15 Aug 2013 01:59 PM
Got it working, thanks.

local humanoid = part and part.Parent and part.Parent:findFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(30)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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