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

Trail Effects Sensor Only Disables One Rather Than Four?

Hi folks, back with another error that I really would like to get to the bottom of. I have sensors located along my track, each of them are supposed to either disable the trail effects from the car whilst airborne or enable them when back on the ground and has touched the sensor. Here's what I've tried, it works but only for one and none of the others.

script.Parent.Touched:Connect(function(Active)
	for i,v in pairs(Active.Parent:GetChildren())do
	if v.Name == "TrailEffects" then
		spawn(function()
		v.Parent.TrailEffects.Trail.Enabled = false
	end)
	end
	end
	end)

As you can see, it's a short script and I'm no doubt missing a lot, but I'm still trying to learn new techniques and such. Thank you all sincerely for any help you can provide me with. Hopefully I can give back to you all when scripting becomes one of my strong points.

1 answer

✓ Accepted answer

It's because by calling

v.Parent.TrailEffects.Trail.Enabled = false

you go to the same object (in other words - first object named 'TrailEffects') Change v.Parent.TrailEffects to just v, so it will be:

v.Trail.Enabled = false

1 comment

0

Thanks, it works fantastically now. I didn't realise it was just a minor error, I was worried I would have to double the amount of lines I have now. Thanks again!

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