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

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

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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.

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. Xoqex 75 — 8y
0
Yeah, you're right. GoldenPhysics 474 — 8y
0
Fixed. (I think.) GoldenPhysics 474 — 8y
0
Wow, I was way off! Looking at your code I see why mine was wrong. Thank you! Supergamerboy1995 129 — 8y
Ad

Answer this question