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 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 + 0.5) local hours = math.floor(time / 60)
codeStarterGui:SetCore("SendNotification", { Title = "Время суток"; Text = string.format("День: %s\nВремя: %02d:%02d", getDayOfWeek(), hours, minutes); Duration = 1; })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
Ваш запрос понятен. Вот, как можно разделить клиентские функции и серверный код:
В клиентском скрипте (поместите в LocalScript в папку StarterPlayerScripts):
lua