hello scripting helpers! i just wanna know if theres an easier way to pick what map to spawn. thats about it
script.Parent.MouseClick:Connect(function() print("button pressed") local Room = math.random(1,2) if Room == 1 then local map = game.ReplicatedStorage.TestMaps.Map1:Clone() print("cloned") map.Parent = game.Workspace print("parent changed") map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1)) wait(0.1) end if Room == 2 then local map = game.ReplicatedStorage.TestMaps.Map2:Clone() print("cloned") map.Parent = game.Workspace print("parent changed") map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1)) wait(0.1) end script.Parent.Parent:Destroy() end)
any help would be nice :)
nvm i got it.
script.Parent.MouseClick:Connect(function() local Kids = game.ReplicatedStorage.TestMaps:GetChildren() local Ran = math.random(1,#Kids) local Fartz = Kids[Ran] local map = Fartz:Clone() print("cloned") map.Parent = game.Workspace print("parent changed") map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1)) end)