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 » Scripters
Home Search
 

Re: Did i break something

Previous Thread :: Next Thread 
Warlock167 is not online. Warlock167
Joined: 11 Nov 2015
Total Posts: 323
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 is not online. 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 is not online. 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 is not online. 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
Warlock167 is not online. Warlock167
Joined: 11 Nov 2015
Total Posts: 323
13 Nov 2015 10:48 PM
thank u added wait() and it doesn't crash anymore

also i like elbows
Report Abuse
Jammer622 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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