I am making a minigame style type game and I want to make an intermission script. How would I do it so it has a countdown and then it TPs the player?
Thanks, Oli.
I am making a minigame style type game and I want to make an intermission script. How would I do it so it has a countdown and then it TPs the player?
Thanks, Oli.
For the countdown just do:
local CountdownTime = 10 --Intermission time
repeat
CountdownTime -= 1
--Make CountdownTime update to clients (gui, surfacegui etc)
until CountdownTime == 0
For teleporting loop through the players:
for _,plr in pairs (game.Players:GetPlayers()) do
plr.Character.HumanoidRootPart.Position = Vector3.new() --Choose this position
end
--Do the round
I will make a GUI tomorrow, then can you help me to put the script in what thing and where.
The script looks like this put together:
local CountdownTime = 10 --Intermission time
local remoteEvent = remoteeventlocationhere
repeat
CountdownTime -= 1
remoteEvent:FireAllClients(CountDownTime)
until CountdownTime == 0
for _,plr in pairs (game.Players:GetPlayers()) do
plr.Character.HumanoidRootPart.Position = Vector3.new() --Choose this position
end
Put the script in ServerScriptService, for the gui make a localscript in StarterGui and make it this:
local remoteEvent = remoteeventlocationhere
remoteEvent.OnClientEvent:Connect(function(CountdownNumber)
--Make CountdownNumber as text in a textlabel
end)
function update(ttime)
game.ReplicatedStorage.updateTime:FireAllClients(ttime - os.time())
end
local ntime = 60 -- in seconds
local ttime = os.time() + ntime
repeat wait() update(ttime) until os.time() >= ttime
for i,v in pairs(game.Players:GetPlayers()) do
local ch = v.Character
repeat wait() until ch ~= nil
local root = ch:FindFirstChild("HumanoidRootPart")
root.Position = Vector3.new(0,0,0)-- position to teleport to
end
The way I do it is to create an infinite loop that invokes 3 functions, intermission(), gamemode() and reset()
intermission()
all it does is doing the countdown and waiting for the minimum players
gamemode()
selects a gamemode/minigame and plays it
reset()
resets the map to start a new round
and for the timer I just put a string value in the workspace and name whatever I want to display messages like āIntermission: 30ā or āRound has ended!ā by just changing itās value, and then reading it on the client
If you want to make multiple intermission type scripts and not only a single one, use this module and then put it in serverstorage. Hereās what you do.
local IntermissionModule = {}
function IntermissionModule.Set(num1, num2, inc, pre)
for i = num1, num2, -inc do
wait(1)
return pre .. ": ".. i
end
end
return IntermissionModule
local ServerStorage = game:GetService("ServerStorage")
local IntermissionModule = require(SeverStorage:WaitForChild("IntermissionModule")
local IntermissionTimeFrame = Intermission.set(30, 1, 1, "Intermission")
while true do
wait(1)
print(IntermissionTimeFrame)
end
EDIT: please correct me if Iām wrong, havenāt been playing with modules in a while
If you would like a more advanced version of the module, I can share it to you.
Remember to make a remote event in replicated storage.
local remoteEvent = remoteeventlocationhere is underlined orange, whatās wrong?
āremoteeventlocationhereā is just a placeholder you must make your own remote event and add the instance there. Example: local remoteEvent = game.ReplicatedStorage.remoteeventname
instance? im not familiar with scripting terms.
Check this page out on remote events/functions Custom Events and Callbacks | Documentation - Roblox Creator Hub PS: Youād be using server to clients
nvm ive got it i think
OnlyThirtyCharacters
itās not working.
That script right now does nothing as the part of the gui and selecting a position to teleport is left for you to code. You could add a print()
somewhere in the script so you can see it works.
how do i script the actual timer which says 3ā¦2ā¦1⦠etc.
local remoteEvent = game.ReplicatedStorage.IntermissionCountdown
local TextLabel = --Your countdown textlabel here
remoteEvent.OnClientEvent:Connect(function(CountdownNumber)
TextLabel.Text = tostring(CountdownNumber)
end)