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

Smoke enabled/disabled script is too out of shape, help?

I have a script in workspace, a model named 'Tycoon', in 'Tycoon' i have another model named 'M1 Abrams', in 'M1 Abrams' i have a model named 'Hull', in 'Hull' i have a union named 'Track', in track i have an effect which is 'Smoke', and in workspace a part named 'road'. I'm trying to get it so when 'Track' touches 'road', the smoke in track gets enabled, if it's not touching road, it gets disabled. It's probably very wrong, but here's what i have for the script:

game.Workspace.Tycoon["M1 Abrams"]["Hull"].Track.Touched:connect(function(road)
game.Workspace.Tycoon["M1 Abrams"]["Hull"].Track.Smoke.Enabled = true
else
game.Workspace.Tycoon["M1 Abrams"]["Hull"].Track.Smoke.Enabled = false
end)

Could someone tell me the correct way to do it and what's my main mistake?

1 answer

✓ Accepted answer

You're code is a little wonky.

local myHull = Workspace.Tycoon["M1 Abrams"]["Hull"]

myHull .Track.Touched:connect(function(road)
	if (road == myHull .Track.road) then
		myHull .Track.Smoke.Enabled = true
	end
end)

myHull .Track.TouchEnded:connect(function(road)
	if (road == myHull .Track.road) then
		myHull .Track.Smoke.Enabled = false
	end
end)

(also might want some variables)

I have never used this event so here's the wiki page.

4 comments

2

I believe you should check to see if the road is touching the track before doing smoke, seeing as something else touching it can set it off as well.

0

Yeah, you're right.

0

Fixed. (I think.)

0

Wow, I was way off! Looking at your code I see why mine was wrong. Thank you!

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