VentDoorClosedV.Changed:Connect(function(value)
if value == true and CrawlerStageV.Value == 3 then
task.wait(3)
if value == true and CrawlerStageV.Value == 3 then
local crawler3 = workspace.Arcanes.Crawler:FindFirstChild("Crawler3")
crawler3:Destroy()
local clone = RSArcanes.Crawler.Crawler1:Clone()
clone.Parent = workspace.Arcanes.Crawler
CrawlerStageV.Value = 1
end
else
end
end)
The thing I want to accomplish is if VentDoorClosedV (aka value) has not changed since the Changed function was called.
This setup I have with the double if statements can work, but if the player changes the value between the 3 seconds, and switch it back, then it would still work. (which I don’t want)
I basically want the script to continue running if value has not changed.
If you need more explanation, that’s totally fine, it’s kind of a rough explanation.
The easiest solution I can think of is adding a global time stamp that is set when the changed event runs as well as saved locally within the event function. Then after the amount of time as expired, you check to see if the global timestamp equals the local one set.
I’m finding it hard to explain in words, so here is my example using your code:
(I added a check in your if statement after waiting 3 seconds)
local currentTimeStamp = tick()
VentDoorClosedV.Changed:Connect(function(value)
local timeStamp = tick()
currentTimeStamp = timeStamp
if value == true and CrawlerStageV.Value == 3 then
task.wait(3)
if value == true and CrawlerStageV.Value == 3 and currentTimeStamp == timeStamp then
local crawler3 = workspace.Arcanes.Crawler:FindFirstChild("Crawler3")
crawler3:Destroy()
local clone = RSArcanes.Crawler.Crawler1:Clone()
clone.Parent = workspace.Arcanes.Crawler
CrawlerStageV.Value = 1
end
else
end
end)
Hope this helps! Let me know if it doesn’t work or if you have any questions.