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: TouchInterest

Previous Thread :: Next Thread 
Vultorz is not online. 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 is not online. Vultorz
Joined: 02 Mar 2015
Total Posts: 2985
18 Jul 2017 10:52 AM
Bump. :/


i like coconuts
Report Abuse
Vultorz is not online. 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
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
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 is not online. 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
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
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 is not online. 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
Customality is not online. Customality
Joined: 11 Aug 2015
Total Posts: 590
18 Jul 2017 11:49 AM
findfirstchild will return nil if the instance isnt found
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