#fixing a script
1 messages · Page 1 of 1 (latest)
because it uses os.time
so people can change the time for it
by changing their devise clock
yo @rugged edge
i fixed it
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local datastores = {}
local function getUTCTime()
local success, response = pcall(function()
return HttpService:GetAsync("http://worldtimeapi.org/api/timezone/Etc/UTC")
end)
if success then
local data = HttpService:JSONDecode(response)
return data.unixtime
else
return os.time()
end
end
Players.PlayerAdded:Connect(function(player)
local userData = DataStoreService:GetDataStore("UserData", player.UserId)
datastores[player.UserId] = userData
local timePlayerLeft = userData:GetAsync("timeLeft") or getUTCTime()
timePassed = getUTCTime() - timePlayerLeft
end)
Players.PlayerRemoving:Connect(function(player)
if not datastores[player.UserId] then
return
end
local timePlayerLeft = getUTCTime()
datastores[player.UserId]:SetAsync("timeLeft", timePlayerLeft)
datastores[player.UserId] = nil
end)
if that dont work ask chatgpt
or use visual studio code
hmm
for debugging
should still work the same right?
yes
okay
btw u have to enable http services @rugged edge
the script gets their time from a website using that
alr
you trying to scam me wit this here?
link takes me to a website that looks completley disfunctional
im just going to ask someone else
wtf is this
your script is already not manupilatable by the player. all you have to do is literally nothing. maybe add game:bindtoclose so it saves properly at all times
i mean i was able to manipulate it myself by just changing my system time
no thats coz you were in roblox studio
datastores dont run on client
does bro not know how os.time() works
datastores run on server
this isnt datastores
clients can change their os clock all they like, this isn't going to change the server's clock

can you do a quick favour for me
go to the documentation
and search up os.time()
the only maybe exception to this is if you're doing this in studio, which is roblox's half-baked attempt at running servers on your client pc. that's not going to be possible in live servers
it will say that the player can manipulate it...
bro do you really think i dont know what os.time does
let me send you a screenshot of the documentation
literally reads "However, users can easily disable sync behavor and set the system time to anything they want"
i can see how you're confused by that
that is talking about using os.time on the client
the client can desync themselves from the server's os.time
ah
that is not going to come up here because datastores only run on the server
so i will be able to manipulate it in studio but not in actual experience?
that's a maybe in studio, i haven't tested it but it seems reasonable because studio tends to run the server side locally. but yeah no in an actual experience, all roblox servers have synchronized os.time meaning they all return the same value. clients cannot mess with that.
yes i am 100% certain of this.
because if you arent then players can just completley cheat it
but alright i trust you
since you have high roles ig
not 100% on the studio side, but regular players aren't going to be opening your game in studio
if they could, you'd have way bigger problems ;p
yeah, you can 100% definitely trust os.time in the actual experience / roblox player, like for regular players joining your game, no issues there. clients cannot tamper with the server's os.time