game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local message = string.lower(msg)
if message == string.lower(";Time ") then
-- get the last number at the end of ;Time and set lighting.ClockTime to it
end
end)
end)
i want to get the last number at the end of “;time” and then set lighting.clocktime to it
You can use string.split to convert your message into an array of strings and see if the player specified a number to set the time to.
local Players = game:GetService("Players")
local Lighting = game:GetService("Lighting")
local timeCommand = ";time"
Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(message)
local splitString = string.split(message, " ")
local command = splitString[1]
local clockTime = tonumber(splitString[2])
if command:lower() == timeCommand:lower() and clockTime then
Lighting.ClockTime = clockTime
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local message = string.split(msg," ")
if message[1] == string.lower(";Time") then
game:GetService(" Lighting").ClockTime = message[2]
end
end)
end)
Wrote this on mobile without testing, may have errors.