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: "if then statement" Looping then Stops

Previous Thread :: Next Thread 
newholland1 is not online. newholland1
Joined: 29 May 2011
Total Posts: 68
20 Aug 2016 06:05 PM
As the brick touches the grass it emits particles but when it is not hitting grass the particles stop. That is my goal for this script, I have been looking through other scripts and I'm kinda confused how to do this. Also I'm think your going to need a looping part to always check if it is hitting "Grass"

So far I have this.

function onTouched(Hit)
if Hit.Name == "Grass" then
script.Parent.Touch.Value = true

if script.Parent.Touch.Value == true then
script.Parent.ParticleEmitter.Enabled = true
end

if script.Parent.Touch.Value == false then
script.Parent.ParticleEmitter.Enabled = false
end

end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
r2go is not online. r2go
Joined: 20 Oct 2011
Total Posts: 88
20 Aug 2016 06:33 PM
This might work? You might need to change the < and > signs around, but this should work.

local GroundPos = workspace.[whehereberthegroundis].Position
local GroudSize = Ground.Size
local AllGround = (GroundSize/2)+GroundPos

function onTouched(Hit)
if Hit == "Grass" then
repeat
if AllGround >= script.Parent.Touch.Position then
script.Parent.Touch.Value = true
script.Parent.ParticleEmitter.Enabled = true
elseif AllGround <= script.Parent.Touch.Position then
script.Parent.Touch.Value = false
script.Parent.ParticleEmitter.Enabled = false
until x = 0
end
script.Parent.Touched:connect(onTouched)
Report Abuse
newholland1 is not online. newholland1
Joined: 29 May 2011
Total Posts: 68
20 Aug 2016 06:54 PM
This is not working... :/

local GroundPos = workspace.[whehereberthegroundis].Position

Do I need to put something here? If so, what? --^
Report Abuse
r2go is not online. r2go
Joined: 20 Oct 2011
Total Posts: 88
20 Aug 2016 07:52 PM
Yeah so I messed up four times here, sorry I messed up so much. :P

First thing is

local GroundPos = workspace.[whehereberthegroundis].Position

I don't know where your ground is located so make a directory to where it is located like "workspace.ground.Position"

Second thing is

Where I put local "AllGround = (GroundSize/2)+GroundPos"

do this

AllGround = (GroundSize/2)+GroundPos + Vector3.new(2,2,2)

Third thing is here(it appears twice in your script) "if AllGround >= script.Parent.Touch.Position then"

Change it to "if AllGround >= script.Parent.Position then"

Fourth thing is add a "wait()" somewhere in the repeat
Report Abuse
newholland1 is not online. newholland1
Joined: 29 May 2011
Total Posts: 68
20 Aug 2016 08:01 PM
until x = 0

I get a red line under "until"
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
20 Aug 2016 08:03 PM
while wait() do
local enabled = false
for _,v in pairs(script.Parent:GetTouchingParts()) do
-- if blah then enabled = true end
end

--do stuff if enabled
end

OR

script.Parent.Touched:connect(function()

end)

script.Parent.TouchEnded:connect(function()

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