generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How can i get this to restart?

Previous Thread :: Next Thread 
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
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
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
25 Jun 2013 10:21 AM
Anyone?
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
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
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
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
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
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
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
25 Jun 2013 10:43 AM
Thanks ;)
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
25 Jun 2013 10:50 AM
No problem.
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
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
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
25 Jun 2013 11:15 AM
Somone please?
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
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
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
25 Jun 2013 11:20 AM
Its a string
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
25 Jun 2013 11:20 AM
And what are you expecting from the string, a player's name?
Report Abuse
TehMostEpicPwner is not online. TehMostEpicPwner
Joined: 20 Aug 2012
Total Posts: 226
25 Jun 2013 11:52 AM
Yes
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image