Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

"if then statement" How to stop it?

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)

1 comment

0

tab your code properly.

1 answer

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

1 comment

0

Okay the value isn't changing when I hit it?

This discussion is preserved as it was. New answers, comments, and votes are closed.