How to constantly get a value from a local script into the server side?

I have a custom tool script in which you can pick up many tools. In a local script, I have a script that whenever you move the camera, the script activates and gives a position of where the tool needs to be. How would I get that value into the server side very quickly the same time it takes to click a click detector on the tool to pick it up?

2 Likes

To be able to transfer anything from the client-side, you require a remote. Remote traffic will always have the bottleneck of how long it takes for a network trip (sending and receiving), so you can never guarantee any instantaneous or constant replication from the client to the server.

2 Likes

Hello, @ScriptingSupport is right, but I’m going to show an example.

Server Side
local replicatedStorage = game:GetService("ReplicatedStorage")
local event = Instance.new("RemoteEvent")
event.Name = "Update"
event.Parent = replicatedStorage

-- Get when it's fired
event.OnServerEvent:Connect(function(player, data, otherData)
    print("Event executed on server side!", player.Name)
end)
Client Side
local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("Update")

local clickDetector
clickDetector.MouseClick:Connect(function()
    event:FireServer("data1", "data2")
end)
2 Likes