Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I disable a value based off another value?

Asked by
Burobuu 18
5 years ago

I've been trying to disable a value based on another value for a certain amount of time. Came up with this, my 3rd version of it. Any better ways I can recreate this or at least make this version work?


while true do repeat wait() until CC.CurrentTrackNumber.Value==22 script.Parent.Value.Value = true wait(5) OpenGates() wait(15) CloseGates() wait(5) script.Parent.Value.Value = false end CC=game.Workspace.CoasterCFrameV4Beta --Ignore functions \/ function OpenGates() local gateopenparts=CC.OpenGates:GetChildren() local gateclosedparts=CC.ClosedGates:GetChildren() for i=1,#gateopenparts do gateclosedparts[i].Transparency=1 gateclosedparts[i].CanCollide=false gateopenparts[i].Transparency=0 gateopenparts[i].CanCollide=true end end function CloseGates() local gateopenparts=CC.OpenGates:GetChildren() local gateclosedparts=CC.ClosedGates:GetChildren() for i=1,#gateopenparts do gateclosedparts[i].Transparency=0 gateclosedparts[i].CanCollide=true gateopenparts[i].Transparency=1 gateopenparts[i].CanCollide=false end end

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Your method is pretty plausible, I don't believe this is much better but it's a lot simpler, you could write it like this?

spawn(function()
   while wait() do --// Sometimes you can forget to write a delay, and overload the Server
      if CC.CurrentTrackNumber.Value == 22 then
         fullProcess()
         script:FindFirstAncestor("Value").Value = false
         break --// I assume you want this to only happen once, if not, simply just remove the 'break'
      end
   end
end)

function fullProcess() --// The cleaner the better
   wait(5); OpenGates(); wait(15); CloseGates(); wait(5)
end

It's also best if you define functions before running a loop as they won't technically be defined yet, I just fixed this by seperating the loop into another thread.

if you have any more auestions or anything else to specify please let me know

Hope this helps

0
Thanks, looks like I need to study a bit more. Burobuu 18 — 5y
Ad

Answer this question