How to clone certain amount of times?

Hi, I am making a game where you type the answer, then blocks appear below you rising you up and escape the lava. However the player can type the answer, I have no idea how to clone the part however long the answer was in letters amount of times, and find if the answer was correct or not. Can someone help me? Thank you so much. Here is my current code:

local questions = {
	"Name an animal",
	"Name an US President"
}
local answers = {
	"dog",
	"cat",
	"mockingjay",
	"goldfish",
	"George Washington",
	"Barack Obama",
	"Abraham Lincoln"
}


game.ReplicatedStorage.SendAnswer.OnServerEvent:Connect(function(player,answer)
		if answer == table.find(answers,answer) then
			local length = #answer
			for i=0,answer do
				local step = Instance.new("Part"):Clone(length)
				step.Name = "Step"
				step.Size = Vector3.new(5,1,5)
				step.CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame
				step.Parent = ChosenMap
			end
		end
	end)

	repeat
		game.ReplicatedStorage.SafeAnswer:FireAllClients()
		Status.Value = questions[math.random(1,#questions)]

		wait(10)

		workspace.Lava.Size += Vector3.new(0,10,0)
game.ReplicatedStorage.SendAnswer.OnServerEvent:Connect(function(player,answer)
		if answer == table.find(answers,answer) then
			local length = #answer
			for i = 1,length do
				local step = Instance.new("Part"):Clone()
				step.Name = "Step"
				step.Size = Vector3.new(5,1,5)
				step.CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame
				step.Parent = ChosenMap
			end
		end
end)

Fixed the middle part for you a bit

1 Like