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 works one way but not another?

Previous Thread :: Next Thread 
somuchbetter is not online. somuchbetter
Joined: 20 Oct 2012
Total Posts: 273
15 Oct 2016 09:08 PM
I have a basic script that kills a player when touching a brick:

function onTouched(whotouched)
whotouched.Parent.Humanoid.Health = 0
end

script.Parent.Touched:connect(onTouched)

I tried to do a seemingly very similar thing to a jar that, when opened, kills anyone touching a radius part (spherical part surrounding the jar). Here is the script for that:

radius = script.Parent
radval = radius.Value.Value

function onTouched(whotouched)
if radval == 1 then
whotouched.Parent.Humanoid.Health = 0
end
end

script.Parent.Touched:connect(onTouched)


Why does the first script work (by work I mean it kills), and the second doesn't?
Report Abuse
somuchbetter is not online. somuchbetter
Joined: 20 Oct 2012
Total Posts: 273
15 Oct 2016 09:09 PM
The value gets changed to 1 when the jar is opened.
Report Abuse
Julian_Orteil is not online. Julian_Orteil
Joined: 14 Aug 2012
Total Posts: 968
15 Oct 2016 09:10 PM
radval = radius.Value.Value <-- Two .Value
Report Abuse
somuchbetter is not online. somuchbetter
Joined: 20 Oct 2012
Total Posts: 273
15 Oct 2016 09:21 PM
Alright, I got it working, but it only works if I leave the area of the sphere then reenter it. Is there a way to make it kill you while you are still in it instantly?
Report Abuse
legomaster38 is not online. legomaster38
Joined: 15 Jan 2010
Total Posts: 305
15 Oct 2016 09:24 PM
print the radius of the inside. Then add on in the script.


print("System processing...")
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
15 Oct 2016 11:10 PM
for _,object in sphere:GetTouchingParts() do
if object:findFirstChild("Humanoid") then
object.Humanoid.Health = -1
end
end
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