function OnTouch()
Instance.new("Smoke",script.Parent:FindFirstChild("Part"))
end
script.Parent.Touched:connect(OnTouch)
I'm trying to insert smoke into any part that comes into contact with the part. Do I possibly need an if~ nil type statement?
function OnTouch()
Instance.new("Smoke",script.Parent:FindFirstChild("Part"))
end
script.Parent.Touched:connect(OnTouch)
I'm trying to insert smoke into any part that comes into contact with the part. Do I possibly need an if~ nil type statement?
I'm new to scripting still, but I'll answer to best of my abilities. Ok, so what's wrong is here, is you never checked for a part that would touch it. Here's how I would do it
local part = script.Parent -- Define the part
function OnTouch(ThingThatTouchedTheBrick) --The thing in brackets is a parameter. I'm still a bit new to scripting, so I'm not great at explaining. But basically, a parameter is a variable in the defintion of a function.
local part = ThingThatTouchedTheBrick --make a variable for the parameter(Not sure if it's necessary, but we'll do it anyway)
if part then --if a part touched it, then we continue
local smoke = Instance.new("Smoke",part) -- creates smoke in the part that touched it
end
end
part.Touched:connect(OnTouch)--connect the event with the function
I hope this helped, and if it did, please accept my answer! :D If you have any questions, feel free to ask me in the comments!
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thanks!