Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why dosent this work i why does it jsut give me and error?

Why is this giving me an error for this script ill show you the error at the bottom and the thing is when yuo click on a gui a mad loades and you telportes but this error comes up.

local gui = script.Parent
local maps = {"grayMap","beigeMap"}

game.ServerStorage.beigeMap.Parent = workspace

gui.MouseButton1Click:connect(function()
	wait(0.1)
	for i,v in ipairs(maps) do
		local map = workspace:FindFirstChild(v)
		if map then
				if i==#maps then
				changeMap(map,maps[1])
				end
				if i~=#maps then
					changeMap(map,maps[i+1])
			end
		end
	end
gui.Visible = false
end)

function changeMap(currentMap,newMap)
	if currentMap then
		workspace[currentMap.Name].Parent = game.ServerStorage
		game.ServerStorage[newMap].Parent = workspace
		for i,v in ipairs(game.Players:GetChildren()) do
			v.Character.Torso.CFrame = workspace[newMap].CFrame+Vector3.new(0,(i*5),0)
		end
	end
end
18:20:48.274 - CFrame is not a valid member of Model

1 answer

This is because you are trying to get the CFrame of a Model instead of a part. Parts have CFrame values, Models do not, so add

.PartName -- after
workspace[newMap]

This discussion is preserved as it was. New answers, comments, and votes are closed.