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: Problem with a For Loop

Previous Thread :: Next Thread 
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:05 PM
This a .PlayerEntered function that is supposed to make a GUI's transparency fade using a for loop. However, it does nothing. I check the value of x's backgroundtransparency after entering and it has not changed. Yes, the script is a localscript.
"BlackScreenAbove" is a text label. Help?

(No output)

function gamestartup(player)
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
end

game.Players.PlayerAdded:connect(gamestartup)
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:07 PM
are you sure there's no output? you can do a few things to check:

a). run the script in a normal script in Play Solo
b). check your output logs in your Roblox appdata folder

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
09 Sep 2012 06:08 PM
function gamestartup(player)
wait(0.1)
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
end

game.Players.PlayerAdded:connect(gamestartup)

-------------------------
~thedestroyer115, nice and helpful posts- sometimes~
Report Abuse
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:10 PM
Application Log
Start: Sun Sep 09 18:03:21 2012

_____________________________________________________

### Shutdown ###

Closing log file
-----------------------------

Was this the log you are looking for?

(It's empty)

I tried it before in a normal script and it resulted in some output error like "LocalPlayer is not a valid member" or something like that.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
09 Sep 2012 06:10 PM
Did you try to do what I did?

-------------------------
~thedestroyer115, nice and helpful posts- sometimes~
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:11 PM
or a better way to do it:

function gamestartup(player)
repeat until player.ChildAdded:wait().Name == "PlayerGui"
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
end

game.Players.PlayerAdded:connect(gamestartup)

MAY not work, but it's still p. cool.

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:11 PM
@thedestroyer
I added the wait

It didn't do anything.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
09 Sep 2012 06:11 PM
Also, that needs to be in a script in workspace.

-------------------------
~thedestroyer115, nice and helpful posts- sometimes~
Report Abuse
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:13 PM
@doombringer
Interesting method
But
It did not work

(Still no output)

I'm concerned that the solution is either
A) A complete syntax error that the system can't pick up on
B) Blatantly obvious
Report Abuse
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:14 PM
It is in Workspace.

It's a local script.
Let me try the scripts posted above in normal scripts instead.
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:15 PM
oh yeah.... why is it in a localscript? that never struck me lol.

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
09 Sep 2012 06:15 PM
OGM IT WON'T WORK IN LOCALSCRIPT!!!! LOCALSCRIPTS ARE CLIENT SIDE ONLY!

-------------------------
~thedestroyer115, nice and helpful posts- sometimes~
Report Abuse
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:19 PM
Sorry for causing you to raig
I was told to put it in a localscript

Besides

I want this function to be local

Anyway
I put it in a normal script
I was getting the error "ScreenGUI is not a valid member of PlayerGui"
So I added a wait BEFORE the function even starts

Cause I deduced that the game had not even created ScreenGui yet
So
It fixed that error
But now
It's still not doing anything
It's in a normal script

wait(1)
function gamestartup(player)
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
end

game.Players.PlayerAdded:connect(gamestartup)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Sep 2012 06:23 PM
function gamestartup(player)

local con
con = player.CharacterAdded:connect(function()
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
con:disconnect()

end)

end

game.Players.PlayerAdded:connect(gamestartup)
Report Abuse
MrIntuitive is not online. MrIntuitive
Joined: 30 Aug 2012
Total Posts: 849
09 Sep 2012 06:28 PM
@AgentFirefox
Wow
Uh
It suddenly worked

THANKS A MILLION EVERYONE!
-MrIntutive
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:30 PM
function gamestartup(player)

repeat until player.CharacterAdded:wait()
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
con:disconnect()

end)

end

game.Players.PlayerAdded:connect(gamestartup)

mine is better :O

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:31 PM
function gamestartup(player)

repeat until player.CharacterAdded:wait()
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
end

game.Players.PlayerAdded:connect(gamestartup)

oops, here's a better version.

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Sep 2012 06:31 PM
"mine is better :O"

....
Shoot.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Sep 2012 06:33 PM
function gamestartup(player)

player.CharacterAdded:wait()
x = player.PlayerGui.ScreenGui.BlackScreenAbove

for i=1, 100, 1 do
x.BackgroundTransparency = x.BackgroundTransparency + 0.01
wait(0.02)
end
end

game.Players.PlayerAdded:connect(gamestartup)



Now mine is better. :)
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:35 PM
game.Players.PlayerAdded:connect(function(player)

player.CharacterAdded:wait()
for i=1, 100, 1 do
player.PlayerGui.ScreenGui.BlackScreenAbove.BackgroundTransparency = player.PlayerGui.ScreenGui.BlackScreenAbove.BackgroundTransparency + 0.01
wait(0.02)
end
end)

now my script will finish some tiny fraction of a second before yours :P

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Sep 2012 06:36 PM
Will it?
I'm not so sure since I saved the location of his frame in a variable. You repeatedly index to the frame.
We should time it to see. :3
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 06:39 PM
well you see lua passes complex data types by reference, so by creating a variable, you actually increase the length of the chain of references, thus adding an operation or two to the processor's stack. theoretically my script would run faster since there are no variables.

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
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