Morphing System messes up Tweens

So there is this strange bug in my game where these tweened moving lollipop platforms are working perfectly fine until you morph into one of the characters. After you morph its position changes and it starts going up higher and you can make it go higher and higher every time you morph. I have no idea how to fix this does anyone know how?

Here’s a video:

Here’s the code:

-- Tween Script
local LStorage = game.Workspace.LollipopStorage

	for i, child in pairs(LStorage:GetChildren()) do
		if child.Name == "LollipopPlatform" then
		local MovingParts = child:GetChildren()
		for i, child2 in pairs(MovingParts) do
		 if child2:IsA("BasePart") then
				local TweenService = game.TweenService
				local Info =

				local PropertyTable = {
					Position = child2.Position +,10,0)
				local OriginalPosition = child2.Position
				local Tween = TweenService:Create(child2, Info, PropertyTable)
-- Morphing Script
local changeEvent = game.ReplicatedStorage:WaitForChild("MorphEvent")

local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")

	local char = player.Character
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso

		local NameTag = game.ReplicatedStorage.NameTag:Clone()
		newChar.Name = player.Name
		newChar.Humanoid.DisplayName = char.Humanoid.DisplayName
		player.Character = newChar
		NameTag.Parent = player.Character


		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
				rootPart.CFrame = plrRoot.CFrame
		newChar.Parent = workspace
		NameTag.Parent = player.Character
		NameTag.CFrame = player.Character.Head.CFrame *,0.65,0)
		local Weld ="Weld")
		Weld.Part0 = NameTag
		Weld.Part1 = player.Character.Head
		Weld.C0 = NameTag.CFrame:inverse()
		Weld.C1 = player.Character.Head.CFrame:inverse()
		Weld.Parent = NameTag
		NameTag.BillboardGui.TextLabel.Text = char.Humanoid.DisplayName
		local NameTagColor = math.random(1,7)
		if NameTagColor == 1 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(85, 255, 0)
		elseif NameTagColor == 2 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
		elseif NameTagColor == 3 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
		elseif NameTagColor == 4 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(0, 0, 255)
		elseif NameTagColor == 5 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(170, 0, 255)
		elseif NameTagColor == 6 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(0, 255, 255)
		elseif NameTagColor == 7 then
			NameTag.BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 255)
		warn("character doesnt exist or something went wrong.")

please supply relevant code with your posts

Sorry, my bad I added the 2 scripts

Is the tween script in StarterGui? If so, try putting it in StarterPlayerScripts, as it would reset on spawn if it was in StarterGui.


Not really sure how this happened, but instead of tweening a platform to move up and down, I recommend using math functions like math.sin or math.cos.
These functions take one value, as if it’s the x position on a graph, and returns a number between one and negative one depending on where on the graph it is.
Anyways, enough explanation. Here’s an example

local value = 0 -- the value to be inserted into the function
local max = 2 --the max high / low of the platform's position
local pos = -- whatever position the platform's at
local platform = --the platform
while wait() do -- forever do
value += 1 -- change this to how or fast you want the platform to move, wouldn't recommend letting the value increase for eternity, though
platform.Position = pos +,math.sin(value)*max)

In this example, the platform, like a wave, will smoothly bob up and down.

you can just change tweeninfo to run the animation back and forth

1 Like

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