|
| 25 Jun 2013 10:10 AM |
My script has a function and I wanted to know how to make the function restart the script look here is my script the rest of the script isn't here so, I just tried a lot , I need some help zi just want the script to end after in the last line of crap is over It ends the script.
function Crap() -- This is what im talking about news.Value = "An error has occoured, restarting game" wait(2) if game.Workspace:findFirstChild("GameMap") then game.Workspace.GameMap:remove() game.Workspace.Finished.Value = true game.Workspace.Winner.Value = "" game.Workspace.PlayerCount.Value = 0 game.Workspace.Running.Value = false wait(5) pls = game.Players:GetChildren() for i = 1, #pls do pls[i].Character:BreakJoints() pls[i].Laps.Value = 0 pls[i].LapValue.Value = 0 pls[i].Playing.Value = false end end end
while wait(0.5) do if game.Workspace.PlayerCount.Value == 0 and game.Workspace.Running.Value == true then Crap() -- This is what tells it to do it elseif game.Workspace.Finished.Value == false then news.Value = "There is currently a race going on..." else Winner = game.Players:findFirstChild(""..game.Workspace.Winner.Value.."") news.Value = ""..Winner.Name.." was the winner of the race!" Winner.leaderstats.Points = Winner.leaderstats.Points + 100 game.Workspace.Finished.Value = true game.Workspace.Winner.Value = "" game.Workspace.PlayerCount.Value = 0 game.Workspace.Running.Value = false wait(5) for i = 1, #pls do pls[i].Character:BreakJoints() pls[i].Laps.Value = 0 pls[i].LapValue = 0 pls[i].Playing.Value = false end end end
|
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Jun 2013 10:24 AM |
| Could you rephrase what you're trying to do. I couldn't make sense of what you wrote. |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2013 10:25 AM |
I wanted to know how to make The end of crap restart my entire script( this is only part) Like at the end of the crap function ends the script from there. |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2013 10:27 AM |
This isn't the best way to do this, but it will work:
function Crap() -- This is what im talking about news.Value = "An error has occoured, restarting game" wait(2) if game.Workspace:findFirstChild("GameMap") then game.Workspace.GameMap:remove() game.Workspace.Finished.Value = true game.Workspace.Winner.Value = "" game.Workspace.PlayerCount.Value = 0 game.Workspace.Running.Value = false wait(5) pls = game.Players:GetChildren() for i = 1, #pls do pls[i].Character:BreakJoints() pls[i].Laps.Value = 0 pls[i].LapValue.Value = 0 pls[i].Playing.Value = false script.Disabled = true script.Disabled = false end end end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 25 Jun 2013 11:03 AM |
But wait I still continues the script to the Winner part.... ): Workspace.Script:103: attempt to index global 'Winner' (a nil value) |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Jun 2013 11:17 AM |
| That means Winner is nil. It means you're looking for a part in the workspace called whatever 'game.Workspace.Winner.Value' is set to, but it doesn't exist. What type of value is it, and what exactly do you want this script to do? Answer that, and I can help you from there. |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Jun 2013 11:20 AM |
| And what are you expecting from the string, a player's name? |
|
|
| Report Abuse |
|
|
| |
|