Skip to content

Commit

Permalink
Fixed infinite error on spring destruction bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dazscripts authored Jul 10, 2024
1 parent 5a71034 commit 88ff4eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Constructors/spring.luau
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ function Class._init(self: Types.Spring, prop: string, instance: Instance)

if not Connection then
Connection = Scheduler:Add(Mode, function(delta: number)
self:_update(TargetLinearPosition, delta);
(instance :: any)[prop] = self._type.FromLinear(self._currentLinearPosition)
if self and self._update then
self:_update(TargetLinearPosition, delta);
(instance :: any)[prop] = self._type.FromLinear(self._currentLinearPosition)
else
if Connection then
Scheduler:Remove(Mode, Connection)
return
end
end

if IsSpringSettled(self._currentLinearPosition, TargetLinearPosition) == true and Connection then
Scheduler:Remove(Mode, Connection)
Expand Down Expand Up @@ -185,4 +192,4 @@ local function spring(springInfo: Types.SpringInfo): Types.Spring
end

-- Returning
return spring
return spring

0 comments on commit 88ff4eb

Please sign in to comment.