Issue with tweening script

Hi, who reads this topic. The issue is that somethinbg wrong i think in the script, i just missed something out so it works weird. The main problem that it literally doesn’t move at all, u can see on the photo:

→ The concept for understanding must be like this:

→ SCRIPT :

local rs = game:GetService("ReplicatedStorage")
local ss = game:GetService("SoundService")
local ws = game:GetService("Workspace")
local ps = game:GetService("Players")
local ts = game:GetService("TweenService")

local TowerFolder = Instance.new("Folder")
TowerFolder.Name = "TowerFolder"
TowerFolder.Parent = workspace

local index = 1

local function buildTower()	
	local part = (index % 2 == 0) and "GreyPart" or "WhitePart"
	
	local folder = rs:FindFirstChild("TowerPartsFolder")
	local placeblePart = folder:FindFirstChild(tostring(part)):Clone()
	local placeblePartPos = placeblePart.Position + Vector3.new(0, index, 0)
	placeblePart.Parent = TowerFolder
	
	if placeblePart then
		local finishPart = ws:FindFirstChild("FinishPart")
		local finishPartPos = finishPart.Position + Vector3.new(0, index, 0)
		--finishPart.Position = finishPartPos > if i add this, should i remove "Vector3.new(0, index, 0)" ?
		
		local startPos = placeblePartPos
		local endPos = finishPartPos
		local goal = { Position = endPos }
		
		local moveInfo = TweenInfo.new(
			3,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.In
		)

		local moveTween = ts:Create(placeblePart, moveInfo, goal)
		moveTween:Play()
		
		task.spawn(function()
			moveTween.Completed:Wait()
			index += 1
		end)
	end
end

while true do
	buildTower()
	
	for i = 1, 3 do
		print("Seconds passed: ", i)
		task.wait(1)
	end
end

Thank you who will help me to fix that and btw ill add like when player touches the part this part frezzed when the player touched it (like a tower game) and I would be very grateful if after the fix you could help implement this idea.

  • I already know how it can be fixed/changed but im looking for working solution and much cleaner in this case*

@SrGolos
@Fietowski
can u help me again?

Have you tried placing a print statement after the if statement to see if it passes? If not then the part does not exist so I suggest printing part and the folder of parts where the suppose parts children.

If it fails the code will look like this

--print this after the line where you first define "part"
print(part, folder:GetChildren())

If you can not find the part varible inside of the table of the folders Children then it’s pretty obvious, the part varible is not correctly formated so it actual works.

You could also try to set the part varible to equal…

local Part = if (index % == 0) then "GreyPart" else "WhitePart"

One more question, why are you waiting on a for loop? Why can’t you just do task.wait(3)?

Blocks exist idk why they arent moving at all

the reason i use this js to check, ill change to task.wait(3):

for i = 1, 3 do
		print("Seconds passed: ", i)
		task.wait(1)
	end

so, in any case i already recode the whole script so it almost works correctly to check a new problem check a new draft in bio

Hey, you already solved your problem??

Furtunately, yep

Hopefully, yepp

Bro, awesome work, seriously, you’re gonna go far

Awesome work, keep it up. I was gone for a bit so I didnt have much time, sorry

thankkk you so muchhhh!!, glad to hear that <3 :blush:

that’s okayy, anyways thankkss :))))