Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"if then statement" How to stop it?

Asked by 7 years ago

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.

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)
0
tab your code properly. BlueTaslem 18071 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Why don't you use else statement like this.

if script.Parent.Touch.Value == true then
    script.Parent.ParticleEmitter.Enabled = true
    else
    script.Parent.ParticleEmitter.Enabled = false
end
0
Okay the value isn't changing when I hit it? newholland1 5 — 7y
Ad

Answer this question