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?
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.