|
| 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 |
|
|
|
| 15 Oct 2016 09:09 PM |
| The value gets changed to 1 when the jar is opened. |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 09:10 PM |
| radval = radius.Value.Value <-- Two .Value |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 15 Oct 2016 09:24 PM |
print the radius of the inside. Then add on in the script.
print("System processing...") |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|