I am currently making an anti-exploit script for my game. My server script is not detecting my event being fired. My event is in ReplicatedStorage. Help would be appreciated.
The player being kicked and the print
works just fine. There are no errors in the output.
Client script:
local function onChanged(Property)
for a,b in pairs(Properties) do
if Property == b then
Event:FireServer(Player, Property)
Player:Kick("Unexpected client behavior detected.")
print(Property)
end
end
end
Humanoid.Changed:Connect(onChanged)
Server script (event function not firing):
local Http = game:GetService("HttpService")
local Event = game.ReplicatedStorage:WaitForChild("Exploit Detection")
function sendEmbed(Player, Property)
local url = "*taken out*"
local data = {
['embeds'] = {{
['title'] = "Exploit Log",
['description'] = Player.Name.." has been kicked for altering their "..Property,
['color'] = 9488629,
}}
}
local finalData = Http:JSONEncode(data)
Http:PostAsync(url, finalData)
end
Event.OnServerEvent:Connect(sendEmbed)
Hey @Aerosphia!
So this is a little quirk with how Roblox handles the :Kick()
method.
Basically, once a player is out of a game, any remote events that are called in their place are thrown out.
What’s happening here is that the player is firing the remote event, and then immediately getting kicked.
The reason this is bad is because the player is removed from the game before the event get’s to the server, ergo throwing it out.
The solution to this is very simple! Instead of kicking the player in the local script, kick them after you’ve finished your Http:PostAsync()
in the server script.
Hope this helped!
2 Likes
Thanks for this reply, but this doesn’t seem to do anything. The function is not being detected at all. If I were to put a print
statement as the first line in the function, it wouldn’t print, even when the RemoteEvent is fired.
I have to be honest, I think my solution is correct, and that you’ve implemented it wrong. Could I see what you changed the code to?
1 Like
Oh!
I added a wait(1)
for testing purposes, but I didn’t see I got an additional error (for concatenating an instance with a string). But that doesn’t matter, it still ran the server function. Thanks! I appreciate it.
1 Like