#i am trying to create admin command to change time multiple in my time script, but it doesn't workin

1 messages · Page 1 of 1 (latest)

unique rock
#

So i have already created some admin commands and they have Admin check so only me can use them and they working, i am succesfully created time script and displaying time into label, but i can't figure out for 3 days how to make admin chat command to just change Multiple variable to another number by it to speed up time.

local TimeUpdate = game:GetService("ReplicatedStorage"):FindFirstChild("TimeUpdate")
local utils = require(game.ServerScriptService.AdminCommands.SpecialDescription:FindFirstChild("CommandUtils"))
local Players = utils.Players
local TimeCounter = {}
TimeCounter.Multiple = 1
TimeCounter.TotalTime = 0
TimeCounter.Minutes = 0
TimeCounter.Hours = 0
TimeCounter.Days = 0
TimeCounter.Months = 0
TimeCounter.Years = 0

while true do
    TimeCounter.TotalTime = TimeCounter.TotalTime + TimeCounter.Multiple
    TimeCounter.Minutes = TimeCounter.Minutes + TimeCounter.Multiple

    if TimeCounter.Minutes >= 60 then
        TimeCounter.Hours = TimeCounter.Hours + math.floor(TimeCounter.Minutes / 60)
        TimeCounter.Minutes = TimeCounter.Minutes % 60
    end
    if TimeCounter.Hours >= 24 then
        TimeCounter.Days = TimeCounter.Days + math.floor(TimeCounter.Hours / 24)
        TimeCounter.Hours = TimeCounter.Hours % 24
    end
    if TimeCounter.Days >= 30 then
        TimeCounter.Months = TimeCounter.Months + math.floor(TimeCounter.Days / 30)
        TimeCounter.Days = TimeCounter.Days % 30
    end
    if TimeCounter.Months >= 12 then
        TimeCounter.Years = TimeCounter.Years + math.floor(TimeCounter.Months / 12)
        TimeCounter.Months = TimeCounter.Months % 12
    end
    
    TimeUpdate:FireAllClients(TimeCounter.Years, TimeCounter.Months, TimeCounter.Days, TimeCounter.Hours, TimeCounter.Minutes)
    wait(1)
end
novel glenBOT
#

studio** You are now Level 1! **studio

unique rock
#
local function onPlayerAdded(player)
    player.Chatted:Connect(function(msg)
        if not utils.isAdmin(player) then return end
        if msg:sub(1,6):lower() == ";time " then
            local args = {}
            for word in msg:gmatch("%S+") do
                args[#args+1] = word
            end
            if args[2] then
                local num = tonumber(args[2])
                if num and num > 0 then
                    TimeCounter.Multiple = num
                end
            end
        end
    end)
end

Players.PlayerAdded:Connect(onPlayerAdded)
for k, player in Players:GetPlayers() do
    onPlayerAdded(player)
end

return TimeCounter