Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
|
| 18 Jul 2017 10:46 AM |
I have a block that if you touch it, you get an invisible forcefield, but the block doesn't seem to do anything.
Code -
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild('ForceField') == true then wait() elseif hit.Parent:FindFirstChild('ForceField') == false then local ff = Instance.new('ForceField', hit.Parent) ff.Visible = false end end)
Normal script, no output(in solo and server). Please excuse any rookie errors, I'm pretty dullheaded when it comes to scripting.
i like coconuts |
|
|
| Report Abuse |
|
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
| |
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
|
| 18 Jul 2017 11:01 AM |
that's a lot of views dang
i like coconuts |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2017 11:09 AM |
Try this:
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("ForceField") then wait() else local ff = Instance.new("ForceField") ff.Parent = hit.Parent ff.Visible = false end end)
|
|
|
| Report Abuse |
|
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
|
| 18 Jul 2017 11:14 AM |
That allows more than one, I want it to only give one.
i like coconuts |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2017 11:19 AM |
Um, no it doesn't? I just tested it, that's what this line is for: > if hit.Parent:FindFirstChild("ForceField") then if the character already has a forcefield, it does nothing, if it doesn't it adds a forcefield and makes it invisible |
|
|
| Report Abuse |
|
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
|
| 18 Jul 2017 11:26 AM |
^ Sorry, I copied it into the wrong block, embarrassing. Thanks for the help!
i like coconuts |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2017 11:49 AM |
| findfirstchild will return nil if the instance isnt found |
|
|
| Report Abuse |
|
|