|
| 20 Jun 2014 09:22 AM |
I'm trying to make a script that when a player in on this brick they have a forcefield but when they leave it the forcefield goes away?
script.Parent.Touched:connect(function(otherPart) if otherPart.Parent:FindFirstChild("Humanoid") ~= nil then print("Player is on plate!") script.Parent.Touched:connect(function(p) if p.Character:FindFirstChild("ForceField") == nil then ff = Instance.new("ForceField",p.Character) else end end) end end)
script.Parent.TouchEnded:connect(function(otherPart) if otherPart.Parent:FindFirstChild("Humanoid") ~= nil then print("Player got off the plate!") script.Parent.Touched:connect(function(p) p.Character.ForceField:Remove() end end end) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 09:23 AM |
| Uhm is TouchEnded a thing? Cause I might use that .-. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 09:23 AM |
| the question mark is suppose to be a period i want it to go awya when they leave the brick. |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jun 2014 09:25 AM |
| When i was explaining what i wanted the script to do i put a question mark after it when it was suppose to be a period. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 20 Jun 2014 10:42 AM |
| Try region3, and Forcefield might be nil. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 10:54 AM |
not sure if this is what you mean, but okay.
script.Parent.Touched:connect(function(hit) local human = hit.Parent:findFirstChild('Humanoid'); if human ~= nil then local ff = human.Parent:findFirstChild('ff'); if ff == nil then local newff = Instance.new('ForceField', human.Parent); newff.Name = 'ff'; end end end) script.Parent.TouchEnded:connect(function(hit) local human = hit.Parent:findFirstChild('Humanoid'); if human ~= nil then local ff = human.Parent:findFirstChild('ff'); if ff ~= nil then ff:Destroy(); end end end)
|
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 04:57 PM |
| Thank you very much verified. |
|
|
| Report Abuse |
|
|