You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want run the “for” loop
What is the issue? Include screenshots / videos if possible!
Its just not running
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local obby = workspace:WaitForChild("Obby")
local Cave = obby:WaitForChild("Cave")
local Gameplayer = Cave:WaitForChild("Gameplay")
local Gate = Gameplayer:WaitForChild("Gate")
local RunesTable = {}
local CorrectOrder = {"Rune3", "Rune1", "Rune4", "Rune2"}
local Runes = workspace:WaitForChild("RuneStand"):WaitForChild("ClickRunes")
local TweenService = game:GetService("TweenService")
local issolved = false
local function isOrderCorrect()
for i, rune in ipairs(RunesTable) do
if rune ~= CorrectOrder[i] then
return false
end
end
return true
end
for i, Rune in ipairs(Runes:GetChildren()) do
for i, Detector in ipairs(Rune:GetChildren()) do
Detector.MouseClick:Connect(function()
print("puzzle")
if not table.find(RunesTable, Rune.Name) then
if #RunesTable >= 4 then
print("Table is full")
else
table.insert(RunesTable, Rune.Name)
if Rune.Name == "Rune1" then
Rune.Color = Color3.new(0.341176, 1, 0.223529)
elseif Rune.Name == "Rune2" then
Rune.Color = Color3.new(1, 0.0823529, 0.0823529)
elseif Rune.Name == "Rune3" then
Rune.Color = Color3.new(0.14902, 0.333333, 1)
elseif Rune.Name == "Rune4" then
Rune.Color = Color3.new(1, 0.894118, 0.298039)
end
Rune.Material = Enum.Material.Neon
end
if #RunesTable == #CorrectOrder then
if isOrderCorrect() then
issolved = true
print("Correct order!")
local start_cf = Gate:GetPivot()
local end_position = Vector3.new(1157.384, 859.865, 2762.123)
local obj = Instance.new("NumberValue")
obj.Value = 0
local openDown = TweenService:Create(obj, TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Value = 1})
obj:GetPropertyChangedSignal("Value"):Connect(function()
local tween_position = start_cf.Position:Lerp(end_position, obj.Value)
local tween_cf = CFrame.new(tween_position) * start_cf.Rotation
Gate:PivotTo(tween_cf)
end)
openDown:Play()
else
print("Incorrect order!")
task.wait(0.5)
for i , rune in ipairs(Runes:GetChildren()) do
rune.Color = Color3.new(0.278431, 0.278431, 0.278431)
end
table.clear(RunesTable)
print(RunesTable)
end
end
else
print("Rune already added")
end
print(RunesTable)
end)
end
end
Hello your script seems fine to me Maybe its an Infinite Yield problem did you try to wait after running the game for about 10 seconds ?? and see what the output + please ss output
script is local , located in starterplayerscripts. And no error in output. As I said above , i tried to add a task wait before loop for 5 seconds , and everything worked fine , sometimes not though.
local TweenService = game:GetService("TweenService")
local RunesTable = {}
local CorrectOrder = {"Rune3", "Rune1", "Rune4", "Rune2"}
local Runes = workspace:WaitForChild("RuneStand"):WaitForChild("ClickRunes")
local issolved = false
warn("HERE 1")
local function isOrderCorrect()
for i, rune in ipairs(RunesTable) do
if rune ~= CorrectOrder[i] then
return false
end
end
return true
end
warn("HERE 2")
for i, Rune in ipairs(Runes:GetChildren()) do
for i, Detector in ipairs(Rune:GetChildren()) do
Detector.MouseClick:Connect(function()
print("puzzle")
if not table.find(RunesTable, Rune.Name) then
if #RunesTable >= 4 then
print("Table is full")
else
table.insert(RunesTable, Rune.Name)
if Rune.Name == "Rune1" then
Rune.Color = Color3.new(0.341176, 1, 0.223529)
elseif Rune.Name == "Rune2" then
Rune.Color = Color3.new(1, 0.0823529, 0.0823529)
elseif Rune.Name == "Rune3" then
Rune.Color = Color3.new(0.14902, 0.333333, 1)
elseif Rune.Name == "Rune4" then
Rune.Color = Color3.new(1, 0.894118, 0.298039)
end
Rune.Material = Enum.Material.Neon
end
if #RunesTable == #CorrectOrder then
if isOrderCorrect() then
issolved = true
print("Correct order!")
local end_position = Vector3.new(1157.384, 859.865, 2762.123)
local obj = Instance.new("NumberValue")
obj.Value = 0
local openDown = TweenService:Create(obj, TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Value = 1})
obj:GetPropertyChangedSignal("Value"):Connect(function()
end)
openDown:Play()
else
print("Incorrect order!")
task.wait(0.5)
for i , rune in ipairs(Runes:GetChildren()) do
rune.Color = Color3.new(0.278431, 0.278431, 0.278431)
end
table.clear(RunesTable)
print(RunesTable)
end
end
end
end)
end
end
warn("HERE 3")