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: why is my basic light script becoming unsynced?

Previous Thread :: Next Thread 
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 02:09 PM
its a script that makes a spinning effect with a circle of lights but its becoming unsynced by 2 seconds after the first loop

http://www.roblox.com/test-item?id=155974300

if you can tell me how to fix the unsync it would be great
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 02:16 PM
B1
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 02:25 PM
;/ no one wants to read the 6 lines of very basic code
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 02:57 PM
No one attempted to look at it ;/
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
04 May 2014 02:58 PM
We're lazy
Paste the code in your forum if you want help
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 03:08 PM

There is a total of 8 blocks with minor changes of wait()
I think this is how it went

--this is in Pointlight 1
while true do
script.Parent.Enabled = false
wait(2)

script.Parent.Enabled = true
wait(16)
end



In the next point light is
while true do
script.Parent.Enabled = false
wait(2)

script.Parent.Enabled = true
wait(18)
end

In the next pointlight is
while true do
script.Parent.Enabled = false
wait(2)

script.Parent.Enabled = true
wait(20)
end

ect...

It gives the looping effect for 1 loop but then it goes out of sync for 2 seconds
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 03:18 PM
Its just easier to look at it hen trying to understand what I said
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 03:29 PM
No one?
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
04 May 2014 03:36 PM
It'd be easier trying to do this in one script
Put all the parts in a model (name them Part1, Part2, ect.)
Put this script inside the model

local main = script.Parent
local currentIndex = 1
local lights = { -- Add more if you need it
main.Part1.PointLight
main.Part2.PointLight
main.Part3.PointLight
}

function advanceIndex()
currentIndex = currentIndex + 1
if currentIndex > #lights then currentIndex = 1 end
end

function returnCurrentAndPrevious()
local currlight = lights[currentIndex]
local prev = currentIndex - 1
if prev < 1 then prev = #lights end
local prevlight = lights[prev]
return currlight, prevlight
end

function switchOff(targ)
targ.Enabled = false
end

function switchOn(targ)
targ.Enabled = true
end

while wait(1) do
local l1, l2 = returrnCurrentAndPrevious()
switchOn(current); switchOff(Previous)
advanceIndex()
end
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
04 May 2014 03:41 PM
Thanks ill try it out
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
04 May 2014 03:59 PM
Whoops, forgot to put commas in that table

local lights = { -- Add more if you need it
main.Part1.PointLight,
main.Part2.PointLight,
main.Part3.PointLight,
}
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
04 May 2014 04:02 PM
Actually, the script I gave you is full of holes

Try this instead

local main = script.Parent
local currentIndex = 1
local lights = { -- Add more if you need it
main.Part1.PointLight,
main.Part2.PointLight,
main.Part3.PointLight
}

function advanceIndex()
currentIndex = currentIndex + 1
if currentIndex > #lights then currentIndex = 1 end
end

function returnCurrentAndPrevious()
local currlight = lights[currentIndex]
local prev = currentIndex - 1
if prev < 1 then prev = #lights end
local prevlight = lights[prev]
return currlight, prevlight
end

function switchOff(targ)
targ.Enabled = false
end

function switchOn(targ)
targ.Enabled = true
end

while wait(1) do
local l1, l2 = returnCurrentAndPrevious()
switchOn(l1); switchOff(l2)
advanceIndex()
end
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
04 May 2014 04:21 PM
Why do you have so many functions?

Lights = {}
Potato = 7 -- Change for the amount of lights you need
for i = 1, Potato do
table.insert(Lights,script.Parent["Part" .. i].PointLight)
script.Parent["Part" .. i].PointLight.Enabled = false
end
while true do
for i,v in pairs(Lights) do
v.Enabled = not v.Enabled
wait(.1)
v.Enabled = not v.Enabled
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