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: What's wrong with this script?

Previous Thread :: Next Thread 
Luxiel is not online. Luxiel
Joined: 16 Jan 2013
Total Posts: 139
31 Jul 2013 10:52 AM
local D = game.Lighting.TimeOfDay

if D == "18:00:00" then
game.Lighting.Brightness = 0.5
end

if D == "19:00:00" then
game.Lighting.Brightness = 0
end

if D == "06:00:00" then
game.Lighting.Brightness = 0.5
end

if D == "07:00:00" then
game.Lighting.Brightness = 1
end
Report Abuse
agentwaffle1234 is not online. agentwaffle1234
Joined: 18 Jul 2012
Total Posts: 50
31 Jul 2013 03:19 PM
The fact that TimeOfDay is not a variable in the "lighting" part of the script.
Report Abuse
Luxiel is not online. Luxiel
Joined: 16 Jan 2013
Total Posts: 139
31 Jul 2013 07:50 PM
Not a variable? What do you mean? It's a valid property inside the "Lighting" service, so I don't see what the problem is.
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
31 Jul 2013 07:52 PM
Add .Value for D and the last line you have.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
31 Jul 2013 07:52 PM
game.lighting.TimeOfDay
Report Abuse
Toughlizard1345 is not online. Toughlizard1345
Joined: 13 Jul 2010
Total Posts: 1077
31 Jul 2013 07:53 PM
Also I'm not sure if this will help but you might need to start the last 3 if statements with elseif
Report Abuse
xXPowerBladeXx is not online. xXPowerBladeXx
Joined: 12 May 2013
Total Posts: 27
01 Aug 2013 09:58 AM
local D = game.Lighting.TimeOfDay

if D == "18:00:00" then

game.Lighting.Brightness = 0.5

elseif D == "19:00:00" then

game.Lighting.Brightness = 0

elseif D == "06:00:00" then

game.Lighting.Brightness = 0.5

elseif D == "07:00:00" then

game.Lighting.Brightness = 1

end
Report Abuse
Luxiel is not online. Luxiel
Joined: 16 Jan 2013
Total Posts: 139
01 Aug 2013 10:02 AM
Substituting "if" with "elseif" rarely ever has an effect on code. I can tell you that that does nothing.
Report Abuse
ricorick is not online. ricorick
Joined: 28 May 2010
Total Posts: 42
01 Aug 2013 10:07 AM
I think you need a value for D but im not so sure...
Report Abuse
9HB is not online. 9HB
Joined: 11 Dec 2012
Total Posts: 2461
01 Aug 2013 10:17 AM
@rickorick

local D = game.Lighting.TimeOfDay

That's the value for D.
Report Abuse
9HB is not online. 9HB
Joined: 11 Dec 2012
Total Posts: 2461
01 Aug 2013 10:19 AM
And Lux what do you mean by 'isn't working' what IS and ISN'T happening? I've never dabbled in lighting but I'll give it a go, for me in solo mode the time does not change, it doesn't progress. Is it changing for you?
Report Abuse
ricorick is not online. ricorick
Joined: 28 May 2010
Total Posts: 42
01 Aug 2013 10:22 AM
Oh...
Report Abuse
Luxiel is not online. Luxiel
Joined: 16 Jan 2013
Total Posts: 139
01 Aug 2013 10:24 AM
For it to change, you must use a script. The script adds to the time and emulates progression. What isn't happening is that when it reaches the designated time, it doesn't change the brightness.
Report Abuse
9HB is not online. 9HB
Joined: 11 Dec 2012
Total Posts: 2461
01 Aug 2013 10:25 AM
Hm. Also you probably want to optimize it later on to change gradually xD I'll look again and post another (most likely useless) solution!
Report Abuse
Luxiel is not online. Luxiel
Joined: 16 Jan 2013
Total Posts: 139
01 Aug 2013 10:27 AM
Yeah, I know. This is just a test script, not the real final product. I wanted to see if I could make this work...if I can't, I'll just keep the brightness at an automatic 0.
Report Abuse
9HB is not online. 9HB
Joined: 11 Dec 2012
Total Posts: 2461
01 Aug 2013 10:30 AM
time = 1
day_night_ratio = 5
night_start = 6

minute = 0
while true do
minute = minute+time
game.Lighting.TimeOfDay = night_start..":"..minute..":00"
if minute > 1440 then minute = 0 end
if minute > 720 then minute = minute+day_night_ratio*time-time end
wait() wait() wait()
end
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
01 Aug 2013 10:32 AM
Extremely inefficient and I feel bad giving you this but, hey it'll work.

local D = game.Lighting.TimeOfDay
while wait(.5) do
if D == "18:00:00" then
game.Lighting.Brightness = 0.5
end

if D == "19:00:00" then
game.Lighting.Brightness = 0
end

if D == "06:00:00" then
game.Lighting.Brightness = 0.5
end

if D == "07:00:00" then
game.Lighting.Brightness = 1
end
end
Report Abuse
9HB is not online. 9HB
Joined: 11 Dec 2012
Total Posts: 2461
01 Aug 2013 10:37 AM
Put this in one script:

local D = game.Lighting.TimeOfDay

if D == "18:00:00" then
game.Lighting.Brightness = 0.5
end

if D == "19:00:00" then
game.Lighting.Brightness = 0
end

if D == "06:00:00" then
game.Lighting.Brightness = 0.5
end

if D == "07:00:00" then
game.Lighting.Brightness = 1
end

put this in another script:

time = 1 --rate of time progression; lower is slower
day_night_ratio = 5 --minutes per day = 1 minute per night
night_start = 6 --hour when night/day start

minute = 0
while true do
minute = minute+time
game.Lighting.TimeOfDay = night_start..":"..minute..":00"
if minute > 1440 then minute = 0 end
if minute > 720 then minute = minute+day_night_ratio*time-time end
wait() wait() wait()
end
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
01 Aug 2013 10:42 AM
Or just this..

times = {}
times["18:00:00"] = 0.5
times["19:00:00"] = 0
times["06:00:00"] = 0.5
times["07:00:00"] = 1
while wait() do
game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight()+1)
if times[game.Lighting.TimeOfDay] then
game.Lighting.Brightness = times[game.Lighting.TimeOfDay]
end
end
Report Abuse
IAmReallyAwesome is not online. IAmReallyAwesome
Joined: 05 Mar 2010
Total Posts: 7371
01 Aug 2013 10:44 AM
Oh my goodness, oh my goodness...

local D = game.Lighting.TimeOfDay
D.Changed:connect(function()
if D == "18:00:00" or D == "06:00:00" then
game.Lighting.Brightness = 0.5
elseif D == "19:00:00" then
game.Lighting.Brightness = 0
elseif D == "07:00:00" then
game.Lighting.Brightness = 1
end
end)

--That SHOULD work.

*Tell me about the rabbits, George*
Report Abuse
9HB is not online. 9HB
Joined: 11 Dec 2012
Total Posts: 2461
01 Aug 2013 10:47 AM
I'm using Luxiels time changer and light changer script and they both work.
Report Abuse
tdog158 is not online. tdog158
Joined: 08 Jul 2008
Total Posts: 5413
01 Aug 2013 10:48 AM
hot potato

local RealSecondToGameMinute = ( 1/2 )
local DayMinutes = 0

while true do
wait( RealSecondToGameMinute )
DayMinutes = math.fmod( DayMinutes + 1, 1440 )
local Hour = math.floor( DayMinutes / 60 )
game.Lighting:SetMinutesAfterMidnight( DayMinutes )
if Hour == 7 then
game.Lighting.Brightness = 1
elseif Hour == 18 or Hour == 6 then
game.Lighting.Brightness = 0.5
elseif Hour == 19 then
game.Lighting.Brightness = 0
end
end
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