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

How can I loop the round part of this while saving the dscore.Value and ascore.Value?

Asked by 4 years ago

First off I'm sorry my formating is horrendous I'm very new to scripting. But if you can read and make sense of this how could I go about looping the round part of this while resting my map and saving the dscore.Value and ascore.Value

Pastebin: https://pastebin.com/DRt65E16

I've yet to add a way for the attacking team to win if that means anything im v lost any help will be appreciated <3

0
I am unable to view your code but when I do anything with rounds I usually use recursion to run an infinite number of rounds. https://www.lua.org/pil/6.3.html ForeverBrown 356 — 4y
0
With resetting the map, at the beginning of the round clone the map from serverstorage to the workspace and set it to a variable in your code. At the end of the round simply destroy the map by using the variable you set earlier. ForeverBrown 356 — 4y
0
For detecting when the attacking team wins, you can use the collection service or tables to keep track of which players are on which teams. When the number of players on a team equals zero then the opposite team wins. ForeverBrown 356 — 4y
0
programmerHere wdym no code? he has a link to PasteBin Luka_Gaming07 534 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Congrats on beginning to script! I'll start by saying that you should definitely have functions here and not just a bunch of free-floating while loops. Furthermore, you should never have more than 1 while true loop. It's difficult to tell what you want with your code, however, I've gone ahead and coded what I interpreted from looking at your code.

I've also reformatted most of your code, hopefully you can see the differences and remember them. The most important would be the unnecessary while true loops that you just end up breaking out of anyway and the false indentation.


local dscore = script.DefenderScore local s = script.Stat local ascore = script.AttackScore local gameStarted = false -- this is intermission local function startGame() t = 5 repeat t = t-1 s.Value = "Game Starting In "..t.." Seconds" wait(1) until t == 0 gameStarted = true s.Value = "Game Starting" wait(2) for i, v in pairs(game.Teams.Orange:GetPlayers()) do v.Character.Head:Destroy() end for i, v in pairs(game.Teams.Blue:GetPlayers()) do v.Character.Head:Destroy() end end local function checkScores() if dscore > 3 then s.Value = "Orange Wins The Game" gameStarted = false end if ascore > 3 then s.Value = "Blue Wins The Game" gameStarted = false end end while gameStarted == true do checkScores() wait(1) end startGame()
0
My code is very basic and leaves a lot of room for you to improve upon. For starters I recommend to disallow ties, and if you really want a challenge, try only calling checkScores() whenever there is a score update. Hint: for the harder challenge you should check out (https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed) GriffthouBiff 147 — 4y
Ad

Answer this question