local laserTweens = {}
local function onTouch2(hit)
-- Irrelevant
end
local function onInstanceAdded2(object)
if object:IsA("BasePart") then
-- Could even do the Spinning from here ?
laserTweens[object] = tweenS:Create(object, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, false, 0), {Orientation = object.Orientation + Vector3.new(0, 360, 0)})
laserTweens[object]:Play()
connections[object] = object.Touched:Connect(onTouch2)
end
end
local function onInstanceRemoved2(object)
if connections[object] then
if laserTweens[object] ~= nil then laserTweens[object]:Cancel() end
connections[object]:Disconnect()
connections[object] = nil
end
end
Whenever a new object is added, it starts spinning. When it goes away, the spinning ends.
Problem is when there’s two. If both are spinning and one goes away, the other also stops (as the other Tween somehow gets Cancelled too).
How would I fix this?