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
