Tween affects part after destroyed

so for some reason the tween im using still affects the part even after the tween has been destroyed

heres my script

self.result = workspace:Raycast(ROOT.Position, ROOT.CFrame.LookVector * -100 + Vector3.new(0, 3, 0), self.will_enemy_collide)
			
			if self.result then
				
				self.instance = self.result.Instance
				self.pos = self.result.Position
				
				local tween = game:GetService("TweenService")
				local info = TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
				local goals = {Position = self.pos}

				self.smash = tween:Create(ROOT, info, goals)
				self.smash:Play()
				
				local x; x = self.smash.Completed:Connect(function()
					local smashFX = ROOT.Slam:GetChildren()
					game.Workspace["Ground-Slam"]:Play()

					for _, v in smashFX do
						v:Emit(20)
					end	
					
					self.smash:Destroy()
					
				end)
			end

here is a video of the problem

Was it destroyed locally? That might be the problem. If so, instead of destroying it in the client sided script, fire a remote event from that script and add some code into a script in serverscriptservice that destroys it on recieving the remote event.

Alternatively,
You can use Tween:Stop()

the tween is destroyed on the server itself
i’ll try stop

:Cancel() did not work as well
this bug is really annoying tbh.

Is it a looped tween by any chance? and is the part anchored?

no the tween is not looped, its just in a function

What I mean is, in the tweenInfo, the repeat count isn’t -1, right?

nope. its 0

000000000000000000

Then I really don’t know the issue. (Sorry!)

Make sure you only call that function once, put a print inside the function to see if it is fired multiple times

looks like that because even if all calls execute, tweens stack and wait

i added the print statements but they only print once
i even tried adding debounce but to no avail

so i managed to fix this problem
i noticed that the random movement of the ROOT would stop when its position was changed, thus i just changed the position of the root as soon as it got hit.

its surprisingly unnoticable, but if someone figures out what was happening, PLEASE let me know!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.