Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is a good way to make a round system?

Asked by 5 years ago

When I try to make a round system (like mad murderer, phantom forces, ect.) I always get lost on how to make it a continuous loop. I am pretty sure while loops and repeats are useful when making these types of scripts but I need a little help on how I could do this.

Here is one of my unfinished scripts.

01local gameFolder = game.ReplicatedStorage.Game
02local events = game.ReplicatedStorage.Events
03local playersInMatch = gameFolder.PlayersInGame
04local currentTime = gameFolder.CurrentTime
05local playersInServer = gameFolder.Players
06local gameInProgress = gameFolder.GameInProgress
07 
08minimumPlayers = 4
09xpReward = 10
10creditsReward = 5
11intermissionTime = 45
12gameTime = 120
13 
14playersInServer.Changed:Connect(function()
15    if playersInServer.Value >= minimumPlayers then
View all 86 lines...

As you can see it is very unorganized and doesn't even loop. I understand how to teleport characters, reward people, and all that stuff. It seems simple when I think of it but once i start scripting everything gets unorganized and confusing. If anyone could possibly give me a simplified example or a list that'd be great. Thank you.

0
lastTick = tick() while true do wait() print(lastTick-tick()) end -- now all u gotta do is turn it into a timer interface.. greatneil80 2647 — 5y

1 answer

Log in to vote
1
Answered by
Farsalis 369 Moderation Voter
5 years ago

Hm, Really Good Question. When i usually go about scripting something, I like to think what I'm doing, why I'm doing it, and how to go about it (Basically meaning do you research first.). So, lets go about thinking on how to start. We need something to countdown to each round right? Let's have a script do that. So how do we countdown time? Well, there are multiple ways. One being os.time() (Usually Preferred). And tick() or....Count! e.g.(thing = thing + 1). Now, when do we start counting down? Well, have check function where a player is added, it check whether there are enough players to start the count. If there is, we count down. Once the countdown is complete, we loop through the players grab the characters, and reposition their root part cframes. Now this same server script starts counting down again (For, however long the round is.). Once it finishes counting down, we loop through the players again and grab the characters root parts cframe, then reposition that cframe back to the lobby. That at-least is the basics of what you might wanna do, excluding winning rewards etc.. How do you not get confused? What helps me is writing down my thoughts, and keeping those in mind. While scripting. And writing down new thoughts if they come to mind (Keeping your thoughts organized.). Anyways, sorry if this got a bit to long. Hope that it Helped slightly.

Ad

Answer this question