Why does this tween add constantly?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

A good tween that doesn’t constantly add!

  1. What is the issue?

The issue is when i step on the part it constantly keeps adding 5 to the position when I only want it do it once!

  1. What solutions have you tried so far?

Finding a solution!

local tweenservice = game:GetService("TweenService")
						for i2, v2 in pairs(v.Parts:GetChildren()) do
							local part = v2

							local pos = part.Position --assuming you aren't using CFrame
							local offset = 5 --5 studs per tween

							local Info = TweenInfo.new(
								0.1,
								Enum.EasingStyle.Bounce,
								Enum.EasingDirection.InOut,
								0,
								false,
								0
							)

							local IncreaseGoals = {
								Position = Vector3.new(pos.X, pos.Y+offset, pos.Z)
							}

							local increaseTween = tweenservice:Create(part, Info, IncreaseGoals)


							increaseTween:Play()
						end

Thank you in advance!

Try adding a debounce to your script.

I tried that didn’t solve the problem!

Move the table IncreaseGoals to the outside of the for i,v in pairs so It only changes it once.

If that did not work for some reason which I’m sure it would then move the whole tween outside.

I don’t think that would work, let me send the full script!

local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local DefaultSize = script.Parent.Size

function determineClosest(EggsAvailable)
	local CurrentClosest = nil
	local ClosestDistance = script.Parent.MaxMagnitude.Value
	for i,v in pairs(EggsAvailable) do
		local Egg = workspace.Eggs:FindFirstChild(v)
		local mag = (Egg.UIanchor.Position-Player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude
		if mag <= ClosestDistance then
			CurrentClosest = Egg
			ClosestDistance = mag
		end
	end
	return CurrentClosest
end




RS.RenderStepped:Connect(function()
	if Player.Character:FindFirstChild("Humanoid") then
		if Player.Character.Humanoid.Health ~= 0 then
			local EggsAvailable = {}
			local CameraRatio = ((Camera.CFrame.Position - Camera.Focus.Position).Magnitude)/11
			script.Parent.Visible = false
			for i,v in pairs(game.Workspace.Eggs:GetChildren()) do
				local mag = (v.UIanchor.Position-Player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude
				if mag <= script.Parent.MaxMagnitude.Value then
					EggsAvailable[#EggsAvailable+1] = v.Name
				end
			end
			if #EggsAvailable == 1 then
				local Egg = workspace.Eggs:FindFirstChild(EggsAvailable[1])
				local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(Egg.UIanchor.Position)
				script.Parent.Visible = true
				script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y)
				script.Parent.CurrentTarget.Value = Egg.Name
				for i,v in pairs(workspace.Eggs:GetChildren()) do
					if v.Name ~= Egg.Name then
						local tweenservice = game:GetService("TweenService")
						for i2, v2 in pairs(v.Parts:GetChildren()) do
							local db = true
							local part = v2

							local pos = part.Position --assuming you aren't using CFrame
							local offset = 5 --5 studs per tween

							local Info = TweenInfo.new(
								0.1,
								Enum.EasingStyle.Bounce,
								Enum.EasingDirection.InOut
							)

							local IncreaseGoals = {
								Position = Vector3.new(pos.X, pos.Y-offset, pos.Z)
							}

							local increaseTween = tweenservice:Create(part, Info, IncreaseGoals)
							if db == true then
								db = false
								increaseTween:Play()
							end
							increaseTween.Completed:Connect(function()
								db = false
							end)
						end
						v.Outline.Color = Color3.fromRGB(255,255,255)
					else
						v.Outline.Color = Color3.fromRGB(0,255,0)
				end
				end
			elseif #EggsAvailable > 1 then
				local Egg = determineClosest(EggsAvailable)
				local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(Egg.UIanchor.Position)
				script.Parent.Visible = true
				script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y)
				script.Parent.CurrentTarget.Value = Egg.Name
				for i,v in pairs(workspace.Eggs:GetChildren()) do
					if v.Name ~= Egg.Name then
						v.Outline.Color = Color3.fromRGB(255,255,255)
					else
						v.Outline.Color = Color3.fromRGB(0,255,0)
					end
				end
			elseif #EggsAvailable == 0 then
				script.Parent.CurrentTarget.Value = "None"
				for i,v in pairs(workspace.Eggs:GetChildren()) do
					v.Outline.Color = Color3.fromRGB(255,255,255)
				end
			end
			script.Parent.Size = UDim2.new(DefaultSize.X.Scale/CameraRatio, DefaultSize.X.Offset, DefaultSize.Y.Scale/CameraRatio, DefaultSize.Y.Offset)
		end
	end
end)

Did you try the fix at least? If you haven’t then try doing so.

I have but the loop has to be there because I am trying to make it so it moves all the parts in the folder!

Are the parts a lot? cause I do have a solution if they aren’t.

They are only 4 parts in the folder

I believe you could get rid of the in-pairs loop and actually make the variable v2 a table that contains the whole 4 parts?

Never mind that doesn’t work I’d suggest just doing separate tweenings for each part and playing it at the same time
edit: I’ve tried it and there aren’t any heavy delays nor noticeable ones It’s actually very synced. (doing separate tweenings)

Can you show your full code, leading from the beginning to here?

local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local DefaultSize = script.Parent.Size

function determineClosest(EggsAvailable)
	local CurrentClosest = nil
	local ClosestDistance = script.Parent.MaxMagnitude.Value
	for i,v in pairs(EggsAvailable) do
		local Egg = workspace.Eggs:FindFirstChild(v)
		local mag = (Egg.UIanchor.Position-Player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude
		if mag <= ClosestDistance then
			CurrentClosest = Egg
			ClosestDistance = mag
		end
	end
	return CurrentClosest
end




RS.RenderStepped:Connect(function()
	if Player.Character:FindFirstChild("Humanoid") then
		if Player.Character.Humanoid.Health ~= 0 then
			local EggsAvailable = {}
			local CameraRatio = ((Camera.CFrame.Position - Camera.Focus.Position).Magnitude)/11
			script.Parent.Visible = false
			for i,v in pairs(game.Workspace.Eggs:GetChildren()) do
				local mag = (v.UIanchor.Position-Player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude
				if mag <= script.Parent.MaxMagnitude.Value then
					EggsAvailable[#EggsAvailable+1] = v.Name
				end
			end
			if #EggsAvailable == 1 then
				local Egg = workspace.Eggs:FindFirstChild(EggsAvailable[1])
				local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(Egg.UIanchor.Position)
				script.Parent.Visible = true
				script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y)
				script.Parent.CurrentTarget.Value = Egg.Name
				for i,v in pairs(workspace.Eggs:GetChildren()) do
					if v.Name ~= Egg.Name then
						local tweenservice = game:GetService("TweenService")
						for i2, v2 in pairs(v.Parts:GetChildren()) do
							local db = true
							local part = v2

							local pos = part.Position --assuming you aren't using CFrame
							local offset = 5 --5 studs per tween

							local Info = TweenInfo.new(
								0.1,
								Enum.EasingStyle.Bounce,
								Enum.EasingDirection.InOut
							)

							local IncreaseGoals = {
								Position = Vector3.new(pos.X, pos.Y-offset, pos.Z)
							}

							local increaseTween = tweenservice:Create(part, Info, IncreaseGoals)
							if db == true then
								db = false
								increaseTween:Play()
							end
							increaseTween.Completed:Connect(function()
								db = false
							end)
						end
						v.Outline.Color = Color3.fromRGB(255,255,255)
					else
						v.Outline.Color = Color3.fromRGB(0,255,0)
				end
				end
			elseif #EggsAvailable > 1 then
				local Egg = determineClosest(EggsAvailable)
				local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(Egg.UIanchor.Position)
				script.Parent.Visible = true
				script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y)
				script.Parent.CurrentTarget.Value = Egg.Name
				for i,v in pairs(workspace.Eggs:GetChildren()) do
					if v.Name ~= Egg.Name then
						v.Outline.Color = Color3.fromRGB(255,255,255)
					else
						v.Outline.Color = Color3.fromRGB(0,255,0)
					end
				end
			elseif #EggsAvailable == 0 then
				script.Parent.CurrentTarget.Value = "None"
				for i,v in pairs(workspace.Eggs:GetChildren()) do
					v.Outline.Color = Color3.fromRGB(255,255,255)
				end
			end
			script.Parent.Size = UDim2.new(DefaultSize.X.Scale/CameraRatio, DefaultSize.X.Offset, DefaultSize.Y.Scale/CameraRatio, DefaultSize.Y.Offset)
		end
	end
end)

Why are you creating the db variable inside of the for loop? Why not just have a global db variable and only execute the for loop when it’s false?