So I have a game where I need a gate to close when the in game time = 10:00 and reopen when it equals 6:30.
Script:
local lighting = game:GetService("Lighting")
repeat
local Time = lighting:GetMinutesAfterMidnight()
if Time >= 1200 and Time < 390 then
script.Parent.Transparency = 0.5
elseif Time < 1200 and Time > 390 then
print("Ran2")
script.Parent.Transparency = 0
end
wait(1/15);
until script.Parent.Name ~= "Gate"
The thing is however that the script works it prints “Ran2” at the right times but it doesnt change the transparency of the part for some reason.
local Lighting = game:GetService("Lighting")
function OpenCloseGate()
if Lighting.ClockTime >= 10 then -- Close gate
script.Parent.Transparency = 0.5
script.Parent.CanCollide = true
elseif Lighting.ClockTime <= 10 and Lighting.ClockTime > 6.3 then -- Open gate
script.Parent.Transparency = 1
script.Parent.CanCollide = false
end
end
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(OpenCloseGate)
lots of edits in case you’re already incorporating this code
I decided to make a quick day and night cycle and fuse it with the function I gave, which is in ServerScriptService. It references the part through workspace. Testing it within a part, it does the same.
EDIT: Ah, we all make some accidents some time. Especially me. Glad to see that it worked for you.