|
| 13 Nov 2015 10:43 PM |
Studio will freeze up completely after 3 seconds when i playtest my baseplate.
I have a script that has the following code:
t = true function entered (Player) wait(1) while t==true do if Player.Character.Humanoid.Health >= 1 then do wait(1) local oof = workspace.Script.Script local s = oof:Clone() s.Disabled = false s.Parent = Player.Character end end end end game.Players.ChildAdded:connect(entered)
and a script inside of that one that has this:
elbow = true
while elbow==true do wait(3) script.Parent.Humanoid.Health = 0 end
after 3 seconds studio just completely freezes though, i'm confused.
|
|
|
| Report Abuse |
|
|
13Jayson
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 1682 |
|
|
| 13 Nov 2015 10:45 PM |
"t = true function entered (Player) wait(1) while t==true do if Player.Character.Humanoid.Health >= 1 then do wait(1) local oof = workspace.Script.Script local s = oof:Clone() s.Disabled = false s.Parent = Player.Character end end end end game.Players.ChildAdded:connect(entered)"
some part of ur script is considered as while true do, so put this instead
"t = true function entered (Player) wait(1) while t==true do wait() if Player.Character.Humanoid.Health >= 1 then do wait(1) local oof = workspace.Script.Script local s = oof:Clone() s.Disabled = false s.Parent = Player.Character end end end end game.Players.ChildAdded:connect(entered)"
Meeooow!!!!!!13!!! |
|
|
| Report Abuse |
|
|
13Jayson
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 1682 |
|
|
| 13 Nov 2015 10:46 PM |
like alway add wait() if ur using while true do
or do while wait() do
btw u dont need to do thing like "elbow = true while elbow ==true do" lol
Meeooow!!!!!!13!!! |
|
|
| Report Abuse |
|
|
13Jayson
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 1682 |
|
|
| 13 Nov 2015 10:46 PM |
unless its for another thing then nvm, but ya add wait() at least
Meeooow!!!!!!13!!! |
|
|
| Report Abuse |
|
|
|
| 13 Nov 2015 10:48 PM |
thank u added wait() and it doesn't crash anymore
also i like elbows
|
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 13 Nov 2015 11:03 PM |
I'm going to cover this too- This part of your code,
if Player.Character.Humanoid.Health >= 1 then do wait(1)
Causes the script to only pause when your character's health is more than [or equal to] 1. If you die, then there will be no wait function for the script to pause at, and the current infinite loop will eat up every free byte of memory your computer has to offer until roblox crashes.
You can just reverse the position of those two lines, and voila.
wait(1) if Player.Character.Humanoid.Health >= 1 then do |
|
|
| Report Abuse |
|
|
Dogejia
|
  |
| Joined: 08 Feb 2012 |
| Total Posts: 1873 |
|
|
| 13 Nov 2015 11:34 PM |
or you can use Humanoid.Changed
Dogemon, gotta pet them all! |
|
|
| Report Abuse |
|
|