Instance.new() object not spawning

Hello, I am making a game where if you guess the correct answer, steps spawn below you. However, it is not spawning any parts no matter how hard I try. Can someone help? Here is my current code:

local answers = {
	"dog",
	"cat",
	"mockingjay",
	"goldfish",
	"george washington",
	"barack obama",
	"abraham lincoln"
}

local Status = game.ReplicatedStorage.Status
local plrs = {}

game.ReplicatedStorage.SendAnswer.OnServerEvent:Connect(function(player,answer)
	local StepsFolder = workspace.StepsFolder
	if answer == table.find(answers,answer) then
		local length = #answer
		string.lower(answer)
		for i = 1,length do
			local step = Instance.new("Part")
			step.Parent = StepsFolder
			step.Color = Color3.new(0.901961, 1, 0.576471)
			step.Name = "testingStep"
			step.Size = Vector3.new(5,1,5)
			step.CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame - Vector3.new(0,1,0)
			print(step.Parent)
		end
	end
end)

Extra details:

  • This is a server script inside of another script which is inside ServerScriptService.
    image

Thanks!

Have a wonderful rest of your day!
-Earthraphobic2

Hi. You will need to ensure that you are setting a Position, otherwise it will default to 0,0,0 and also make sure the part is Anchored and/or CanCollide is on, otherwise it will fall out of the environment.

1 Like

Hi, thanks for getting back to me. I have anchored the part, and changed CFrame to Vector3/Position, however it is still not spawning in? Heres a picture of “Explorer” when its supposed to spawn in:
image

parts can only spawn in under workspace

Yes, the folder is in workspace because I said that StepsFolder = workspace.StepsFolder

Output errors?

…,.,…,…,.,…,awdaa

None.

oifwejwefijwe;lfkwfewefwfeweffwefwewef

1 Like

Maybe its not the Instance.new() that’s not working, can you make it print something after the answer if statement?

if answer == table.find(answers,answer) then
	print("Answer found")
1 Like

I see the issue, replace

if answer == table.find(answers, answer) then

with

if table.find(answers, answer, 1) then
2 Likes

Thank you so much, it spawned for me now. However it is not changing position.

step.CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0, 1, 0 )

try replace where you set cframe with this