✓ Accepted answer
Problem #1: Occurrence
The reason nothing's printing is because your chat event isn't established with the local player. You're waiting for PlayerAdded, which will fire when other players join the game, but not yourself. You've already loaded in by the time this code is running.
Problem #1 Solution
You should separate the code for that event into a function, so you can apply it to yourself and other players when they join the game. Reusable code is happy code.
local Players = game:GetService("Players")
local function PlayerJoined(player)
end
PlayerJoined(Players.LocalPlayer)
Players.PlayerAdded:Connect(PlayerJoined)
Problem #2: Logic
There's a small logic problem with your code, that has to due with your timevalue variable. If I understand you correctly, you want the user to be able to chat .timeset followed by any range of numbers you give it. Right now, you're using comparative operations such as greater than or equal too and less than or equal too. These will return booleans, not numbers.
Problem #2 Solution
What you want do it, is get the user's message first, then analyze the numbers in their message string.
local Players = game:GetService("Players")
local function PlayerJoined(player)
player.Chatted:Connect(function(message)
if message:sub(1, 9) == ".timeset " then
local timevalue = tonumber(message:sub(10))
if timevalue and timevalue >= 10 and timevalue <= 720 then
print(timevalue)
end
end
end)
end
PlayerJoined(Players.LocalPlayer)
Players.PlayerAdded:Connect(PlayerJoined)
That's all there is to it, hope this helped, let me know if you have any questions.
1 comment
You should indent your code correctly.