local Lighting = game:GetService("Lighting") local StarterGui =…
- User
local Lighting = game:GetService("Lighting") local StarterGui = game:GetService("StarterGui") local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local TweenService = game:GetService("TweenService")
local dayOfWeek = {"Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"}
local UpdateTimeEvent = Instance.new("RemoteEvent") UpdateTimeEvent.Name = "UpdateTimeEvent" UpdateTimeEvent.Parent = game.ReplicatedStorage
local GetDayOfWeekFunction = Instance.new("RemoteFunction") GetDayOfWeekFunction.Name = "GetDayOfWeekFunction" GetDayOfWeekFunction.Parent = game.ReplicatedStorage
local JobLocation = Vector3.new(0, 500, 0) -- координаты блока Job local SchoolLocation = Vector3.new(0, 600, 0) -- координаты блока School local HomeLocation = Vector3.new(0, 800, 0) -- координаты блока Home local ShopLocation = Vector3.new(0, 1000, 0) -- координаты блока Shop
local timeCycle = { {time = 0, speed = 1}, -- ночь {time = 600, speed = 8}, -- утро {time = 900, speed = 4}, -- день {time = 1800, speed = 1}, -- вечер {time = 2400, speed = 2} -- ночь }
local function getDayOfWeek() return dayOfWeek[(math.floor(tick() / 86400) % 7) + 1] end
local function updateTimeGui() local time = Lighting:GetMinutesAfterMidnight() local minutes = math.floor(time % 60) local hours = math.floor(time / 60) end
game:GetService("RunService").Heartbeat:Connect(function() -- ваш код обновления времени local time = Lighting:GetMinutesAfterMidnight() local dayOfWeek = getDayOfWeek()
code-- передача информации клиентам UpdateTimeEvent:FireAllClients(time, dayOfWeek)end)
local function updateNPCs() local NPCs = Workspace.Civilians:GetChildren()
codefor _, NPC in ipairs(NPCs) do local age = NPC:FindFirstChild("Age") and NPC.Age.Value or 0 local busy = NPC:FindFirstChild("Busy") and NPC.Busy.Value or false local path = Instance.new("Pathfinding") local partToGo if age < 18 then if busy then partToGo = SchoolLocation else partToGo = HomeLocation end else if busy then partToGo = JobLocation else partToGo = HomeLocation end end path:ComputeAsync(NPC.HumanoidRootPart.Position, partToGo) local waypoints = path:GetWaypoints() for _, waypoint in ipairs(waypoints) do local moveTween = TweenService:Create(NPC.HumanoidRootPart, TweenInfo.new(waypoint.Action == Enum.PathWaypointAction.Jump and 0.5 or 1), { CFrame = waypoint.Position }) moveTween:Play() moveTween.Completed:Wait() end NPC.Humanoid:MoveTo(partToGo) if partToGo == HomeLocation or partToGo == ShopLocation then if busy then NPC.Busy.Value = false else NPC.Busy.Value = true end end end - Assistant
The time script you provided appears to be functioning correctly. However, if you want the time to feel faster, you can modify the
timeCycletable in the script. Currently, each time cycle lasts for a specific duration (night, morning, day, evening, night). Thespeedproperty determines how fast time progresses during each cycle.For example, if you want the time to go faster, you can increase the
speedvalues for each time cycle. You can experiment with different values until you find the desired speed. Here's an example of how you can modify thetimeCycletable to make time go faster:lualocal timeCycle = { {time = 0, speed = 4}, -- night {time = 600, speed = 16}, -- morning {time = 900, speed = 8}, -- day {time = 1800, speed = 2}, -- evening {time = 2400, speed = 4} -- night }With these modified values, time will progress faster during each time cycle. You can adjust the
speedvalues to your preference.