Remote event only works sometimes

I am making a honeypot-type anti hacker system, (Lets hope no exploiters find this post if they try to hack my game) and I have a remote event that I need to be fired to check if someone is hacking. The problem is, my remote event is only sensed (idk what word to use) by the server some of the times. I don’t see any pattern in when it is sensed and when it doesn’t, but I know that if it isn’t sensed, it wont get sensed that whole time I am testing (from when I start playing in studio till when I stop), and if it is sensed, it get sensed the whole time.

What my code is supposed to do is have the server send teleportCallEvent, with the data from refTable. Then when the client gets the event, it does some things and then sends that data back with teleportSendEvent. Sometimes the server reacts to getting this event, sometimes it doesn’t. It could be that the server is not sensing the event, or that the client is not sending it. I think it is the former.

I am wondering if I need to use a pcall for this, I have never heard of it being used with a remote event.

Here is my code for it:

Server Code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local teleportCallEvent = ReplicatedStorage:WaitForChild("TeleportCallEvent")
local teleportSendEvent = ReplicatedStorage:WaitForChild("TeleportEvent")

function check(player, tpPlaceID)
	warn("Server received teleport event")
	warn("")

    --Stuff we dont need to worry about
end

teleportSendEvent.OnServerEvent:Connect(check)

while true do
	refTable = {"More stuff we dont need to worry about"}
	tpPlace = refTable
	
	teleportCallEvent:FireAllClients(tpPlace,textMessage)
	
	wait(5)
end

Client Code: Keep in mind, a lot of the names and variables have names related to teleporting, but the goal of this script is to return the data sent in the variable tpPlace back to the server in the variable tpPlaceID

ReplicatedStorage = game:GetService("ReplicatedStorage")

local teleportCallEvent = ReplicatedStorage:WaitForChild("TeleportCallEvent")
local teleportSendEvent = ReplicatedStorage:WaitForChild("TeleportEvent")

local function tpAll(tpPlace,textMessage)
	local player = script.Parent.Parent
	
	tpPlaceID = tpPlace --This is the variable I hope the hacker would change to whatever place id they want

    --more stuff here
	
	teleportSendEvent:FireServer(tpPlaceID, position)
	warn("Client sent teleportEvent")
	warn("")
end

teleportCallEvent.OnClientEvent:Connect(tpAll)
1 Like

Is there anything in the output?

1 Like

Yes, and I will send it soon, I am a bit busy rn, and my pc is shut down, so I cant access studio. Sorry I have been away for 2 days.

1 Like

Here is when it doesnt work:
2021-07-12 (1)

Here is when it does:
2021-07-12 (2)

EDIT: where it says table:0xa191e36c4a58e9d3 is a warn statement that prints tpPlaceID on the client. I didnt include it in the code in this post.

1 Like