I have a variable in a folder called VAR in the workspace, which DEFINITELY becomes true after the end of a script, because I got it to print it. However, this while loop isn't working. It's supposed to be cloning a model in ServerStorage into different positions, but the script doesn't run at all. Please help! Thank you.
while game.Workspace.VAR.timeformon.Value==true do local modal = game.ServerStorage.IODOLLARS:Clone() modal.Parent=game.Workspace modal.Position=Vector3.new(98.05, 4.05, 228.65) local modol = game.ServerStorage.IODOLLARS:Clone() modol.Parent=game.Workspace modol.Position=Vector3.new(76.75, 2.85, 219.85) local modl = game.ServerStorage.IODOLLARS:Clone() modl.Parent=game.Workspace modl.Position=Vector3.new(89.45, 6.95, 191.55) local modlo = game.ServerStorage.IODOLLARS:Clone() modlo.Parent=game.Workspace modlo.Position=Vector3.new(82.05, 18.05, 228.55) game.Workspace.VAR.timeformon.Value=false end
I think what's happening here is that the script is going past the while loop before the value is true, so it never runs that code. Since the script cant move back up when you change it to true, you need to use something like an event. Theres an event called :GetPropertyChangedSignal() that should do you well.
local timeformon = game.Workspace.VAR.timeformon timeformon:GetPropertyChangedSignal("Value"):Connect(function() while game.Workspace.VAR.timeformon.Value == true do wait() --put all that code from earlier here end end)
Instance:GetPropertyChangedSignal() triggers when the given property is changed, and the while loop will stop running whenever its condition goes to false, so it should work just fine.