Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does tick() return the player?

im making a ping displayer thingy and for some reason i enter tick and it returns the player

localscript (yes it is inside of startergui)

while true do
	local ping = game:GetService("ReplicatedStorage").Remotes.getPing:InvokeServer(tick())
	script.Parent.Text = tostring(ping)
	task.wait(0.1)
end

Serverscript:

game:GetService("ReplicatedStorage").Remotes.getPing.OnServerInvoke = function(old)
	print(old)
end

it prints my roblox name, why?

Also the problem seems to be serversided because i printed tick on the client and it worked

2 answers

do function(plr, old)

Because the client is sending data to the server, for security reasons, roblox lets you know which player is sending the data everytime it's invoked and it's an automatic parameter given to the server. Therefore, the parameters you pass will be the second, third, etc. values passed to the function.

You probably shouldn't use tick(), Roblox has provided superior features such as DateTime.now().UnixTimestamp. Anyways, Roblox by default sends the Player instance and whatever else you decided to send over the remote. You can ignore the Player instance with the following:

game:GetService("ReplicatedStorage").Remotes.getPing.OnServerInvoke = function(_, old)
    print(old)
end

1 comment

1

you can use os.time() and workspace:GetServerTimeNow()

This discussion is preserved as it was. New answers, comments, and votes are closed.