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: Help me lol

Previous Thread :: Next Thread 
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 09:15 PM
So I've been getting help around the forums about this, the script below is supposed to be a day/night cycle that turns lights on and off. the SpotLight is inside a part named "Lightpart" and that is inside a group. I do not understand what I am doing wrong, if someone could help me out I'd greatly appreciate it. Thanks.

minutesAfterMidnight = 0

while true do

minutesAfterMidnight = minutesAfterMidnight + 1
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

end

while true do
wait()
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == "Lightpart" then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
SpotLight.Enabled = false
Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
SpotLight.Enabled = true
Material = Enum.Material.Neon
end
end
end
end
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 09:26 PM
bump
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 09:43 PM
bump 2
Report Abuse
Tunicus is online. Tunicus
Joined: 16 Feb 2013
Total Posts: 3165
21 Oct 2017 09:52 PM
1. The first while loop is obstructing the bottom portion. The while loop runs indefinitely, and scripts run from top to bottom, so there's no way the script will ever reach the bottom loop.

2. AFAIK this is the only script affecting the TimeOfDay, so you only need to set the materials and spotlight whenever the lighting is changed. Just put the bottom portion (excluding the while loop) inside of the first loop.

3. "SpotLight.Enabled = true"
"Material = Enum.Material.Neon"

You aren't indexing anything here, this should be

v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 10:01 PM
Thank you sooo much.
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 10:31 PM
So it works now, kinda. The day/night cycle works now, but lights do not react to the day change. If I had to guess I messed up on the "for i,v". Any suggestions?

New code:

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == "Lightpart" then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end



Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 10:52 PM
Bump
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 11:06 PM
bump?
Report Abuse
kylerzong is not online. kylerzong
Joined: 06 Aug 2011
Total Posts: 659
21 Oct 2017 11:07 PM
minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 11:11 PM
What's the difference between v.Name and v.FindFirstChild?
Report Abuse
s3vvy is not online. s3vvy
Joined: 24 Feb 2011
Total Posts: 983
21 Oct 2017 11:13 PM
^ yikes


Subscribe for scripting tutorials and more videos! www.youtube.com/c/SPiNClan
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
21 Oct 2017 11:15 PM
Also, unfortunately, still no luck :/
Report Abuse
NemeAero is not online. NemeAero
Joined: 25 Nov 2016
Total Posts: 410
21 Oct 2017 11:23 PM
minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end

minutesAfterMidnight = 0


while true do
wait()

minutesAfterMidnight = minutesAfterMidnight + 10
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
wait(0.1)

for i,v in pairs(game.Workspace:GetChildren()) do
if v:findFirstChild("LightPart") then


if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
v.LightPart.SpotLight.Enabled = false
v.Material = Enum.Material.Plastic
end

if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
v.SpotLight.Enabled = true
v.Material = Enum.Material.Neon
end
end
end
end


This message has been approved by @NemeAero on ROBLOX, Twitter, and Instagram! Go follow me!
Report Abuse
DrGorgeousFreeman is not online. DrGorgeousFreeman
Joined: 05 Dec 2012
Total Posts: 109
22 Oct 2017 12:03 AM
:l
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