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

My minigame script picks a number between 1 and 2 and always picks 2, any ideas?

So I'll show the part where it picks the map, I have 2 maps and it's supposed to randomly pick one of them in a loop. Whenever it picks one, it always picks the number 2. Any ideas?

m = Instance.new('Message', workspace)
h = Instance.new('Hint', workspace)
local sword = game.Lighting.ClassicSword:Clone()
map = game.Lighting.SF:Clone()
map2 = game.Lighting.Obby:Clone()
players = game.Players:GetChildren()

while true do
	num = math.random(1,2)
	wait(1)
	for i = 5, 1, -1 do
		h.Text = "Choosing map in: "..i
		wait(1)
	end
	h:Remove()

Here is the script for the first map:

if num == 1 then -- if the first map is picked
		h = Instance.new('Hint', workspace)
		m.Text = "Map Number "..num.." Has Been Chosen!"
		wait(3)
		m.Text = "Sword Fight, Created by EternallySpeedy"
		wait(3)
		m.Text = "Be the last one alive!"
		wait(3)
		m:Remove()
		wait(1)
		h.Text = "Loading Map..."
		wait(2)
		map.Parent = game.Workspace -- loading the map
		map.Name = "Map"
		map:MakeJoints()
		h.Text = "Teleporting Players..."
		wait(2)
	    h:Remove()
		target = Vector3.new(48.7, 0.5, 32.455) -- teleporting the players
		for i, v in pairs(game.Players:GetChildren()) do
		v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0))
		m = Instance.new('Message', workspace)
		h = Instance.new('Hint', workspace)
		m.Text = "3"
		wait(1)
		m.Text = "2"
		wait(1)
		m.Text = "1"
		wait(1)
		m.Text = "Begin!"
		wait(1)
		m:Remove()
		sword:Clone().Parent = game.Players.LocalPlayer.Backpack
		end
		for i = 60, 1, -1 do
			h.Text = "Round ends in: "..i -- countdown until the round is over
			wait(1)
			end
		h.Text = "The round is over."
		wait(1)
		map:Remove()
		wait(5)
	for i = 15, 1, -1 do  
		h.Text = "Intermission: "..i
		wait(1)
		end
		m:Remove()
		h:Remove()
		m = Instance.new('Message', workspace)
		h = Instance.new('Hint', workspace)

Next is the script for the 2nd map, it is continued off of the first map with an elseif:

elseif num == 2 then -- If the second map is picked
		h = Instance.new('Hint', workspace)
		m.Text = "Map Number "..num.." Has Been Chosen!"
		wait(3)
		m.Text = "Obby 1, Created by EternallySpeedy"
		wait(3)
		m.Text = "Be the first to finish!"
		wait(3)
		m:Remove()
		wait(1)
		h.Text = "Loading Map..."
		wait(2)
		map2.Parent = game.Workspace -- loading the map
		map2.Name = "Map2"
		map2:MakeJoints()
		h.Text = "Teleporting Players..."
		wait(2)
		target = Vector3.new(66, 0.2, 215) -- teleporting players
		for i, v in pairs(game.Players:GetChildren()) do
		v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0))
		m = Instance.new('Message', workspace)
		h = Instance.new('Hint', workspace)
		m.Text = "3"
		wait(1)
		m.Text = "2"
		wait(1)
		m.Text = "1"
		wait(1)
		m.Text = "Begin!"
		wait(1)
		m:Remove()
		end
		end
		for i = 60, 1, -1 do -- countdown until the round is over
			h.Text = "Round ends in: "..i
			wait(1)
		end
		h.Text = "The round is over."
		wait(1)
		map2:Remove()
		wait(5)
	for i = 15, 1, -1 do
		h.Text = "Intermission: "..i -- countdown until the loop restarts
		wait(1)
		end
		m:Remove()
		h:Remove()
		m = Instance.new('Message', workspace)
		h = Instance.new('Hint', workspace)
end

1 comment

0

I honestly don't see a problem with the script. What I think you have here is very large luck. :D

1 answer

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