Dealing with the Touched event and their unescapable delay

Okay, So i’ve been trying to use the touched event but the delay is really bad, Its really getting to me.

local part = script.Parent
local RE = game.ReplicatedStorage.remoteEvents

part.Touched:Connect(function(hit)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if plr then
		RE.DGT:FireClient(plr)
	end
end)

Maybe you have a lot of connections in your game, or maybe the remote is getting delayed. Are you lagging by any chance?

1 Like

Could we see the local script where it’s getting received

1 Like
local TP = game.Workspace.Map.Outside["Baguette Area"].DGT
local LT = game.Players.LocalPlayer.PlayerGui:WaitForChild("TextGui").Text3
local RE = game.ReplicatedStorage.remoteEvents
local MP = game.Workspace.Map.Outside["Baguette Area"].DGT

RE.DGT.OnClientEvent:Connect(function()
local Goal = "No! Don't go there!"

for i = 1, #Goal do
    LT.Text = Goal:sub(1,i)
            task.wait()
       end
end)

No, I get 60 ms and I’m pretty sure thats a low ping

Try debugging by putting a print statement under the touched event and then another one under the onclient event and then we will be able to see what is slow

1 Like

It seems like the client sided script was slow, Is there anyway to fix it?

Are you calling the event as soon as you join the game, perhaps stuff is still loading

If not then you should probably handle the touched event on the client as there is not much need of handling it on the server this should definitely increase speed a little

1 Like

Oh, I never thought of that. Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.