Tweening problem!

for some reson this doesnt work

serverscript

local stadardTimerInScript = 30
			local timerInScript = 30
			local killBlocksTimer = 6
			local KillBlocksTimerUse = 6
			
			repeat
				if KillBlocksTimerUse == 0 then
					local moveBlocks = game:WaitForChild("ReplicatedStorage"):WaitForChild("MoveBlocks")
					if moveBlocks.Value == true then
						moveBlocks.Value = false
					elseif moveBlocks.Value == false then
						moveBlocks.Value = true
					end
					KillBlocksTimerUse = killBlocksTimer
				end
				timer.Value = timerInScript.." seconds left!"
				timerInScript -= 1
				wait(1)
				KillBlocksTimerUse -= 1
			until timerInScript <= 0

other server script:

local tweenService = game:GetService("TweenService")

local killBlocksAmount = #game.Workspace.MiniGameFolder.KillBlockFolder:GetChildren()

game:WaitForChild("ReplicatedStorage"):WaitForChild("MoveBlocks"):GetPropertyChangedSignal("Value"):Connect(function()
	
	math.random(1,killBlocksAmount)

	local killBlockToMove = game.Workspace.MiniGameFolder.KillBlockFolder:FindFirstChild("KillBlock"..tostring(killBlocksAmount))

	local Info = TweenInfo.new(
		5,
		Enum.EasingStyle.Quart,
		Enum.EasingDirection.In,
		0,
		true,
		0
	)

	local oldXPos = killBlockToMove.CFrame.Position.X
	local oldYPos = killBlockToMove.CFrame.Position.Y
	local newZPos = killBlockToMove.CFrame.Position.Z -65

	local Goals = 
		{
			Position = Vector3.new(oldXPos, oldYPos, newZPos);
			Color = Color3.new(1, 0, 0)
		}

	local KillPartTween = tweenService:Create(killBlockToMove, Info, Goals)
	KillPartTween:Play()
	wait(5)
end)

can you specify when it doesn’t work? If you don’t know you can debug your code.

1 Like

it stops randomly and then it goes and do it again instead of a random part

You say it does it again instead of a random part, but you never declared a random part.

Check your output for an error, if there is one, maybe we can help. To open output, goto view tab in studio, you’ll find it there.

there are no errors____________

it should get a new random part

but where is it written?
i don’t see in your code anywhere that it generates a random part

second script and the line 8___

line 8 is empty? do you mean line 7? well you do generate a random number in line 7 but you don’t actually do anything with it.

your right sorry I din’t see that

you should replace line 9 with

local killBlockToMove = game.Workspace.MiniGameFolder.KillBlockFolder:FindFirstChild("KillBlock"..tostring(math.random(1, killBlocksAmount)))

hope that’s the solution

but every time it happends for some reason it still will always choos block 1

I dont like the way your writing this
Make a print to see which one it chose

local folder = workspace.MiniGameFolder.KillBlockFolder
local randomBrick = folder[math.random(#folder)]
print(randomBrick)