Help with detecting player kicks. - FAKING GAME INSTANCES

So currently by the title, you might think this is some ordinary thing. But it’s not.
What I am doing is trying to sandbox game, which will return a sandboxed version of whatever is trying to get grabbed.
It’s hard to explain so here is an example.

local Players = game.Players -- What's going on here is game is sandboxed, so they key would be "Players". And if it finds a service named "Players" then it will return a sandboxed version of that too.

Heres a quick look at my metatable.

meta.__index = function(s,k)
				print(k) -- When I tried kicking myself with "Players", this didn't print anything.
				local G = game:FindFirstChild(k)
				if G then
					return OverwriteUserData(G)
				end
				if att then -- Variable att has been removed because privacy.
					return att
				else
					return OverwriteUserData(Real[k])
				end
			end
			meta.__newindex = function(s,k)
				return OverwriteUserData(Real[k])
			end

Some code I will not share due to privacy reasons.
The issue here is that it’s not detecting when I kick myself, aka kicking a player.
EVEN though it’s a sandboxed version of players, it still won’t for some reason.
When writing this, I tried fixing it myself, but no luck.
Here’s a screenshot of the output printing “s,k”
output

2 Likes

I don’t see anything wrong from a glance. Could you post the OverwriteUserData function? Also make sure you’re recursively wrapping everything.

If you want to wrap Roblox classes, you might want to look at this tutorial: How to wrap Roblox instances to allow for custom properties

I know you already have a solution, but if you use the code there as a template, since you don’t want to share the specific code that is causing the problem, this might be able to guide you.

This is for a sandbox. Custom properties are not needed.

The principle is the same - you’re wrapping the Roblox class via a userdata. The only difference is, instead of adding new methods, you’re overwriting existing ones.

Have you actually overridden the Kick method? Since you’re doing this in Studio, it’s possible that Kicking the user causes some sort of issue. Try overwriting that method and then seeing if it works or not.

I was thinking of overwriting the kick method, but then as said again, I can’t get the method.
I was printing “s,k”, the object, and the method.
I also showed the output, k printed nil/nothing. whenever calling kick method.

After removing

return OverwriteUserData(Real[k])

It didn’t kick me.
After putting it back, it kicked me.
for “k”, it is nil.
You can’t check the kick method as far as i’m seeing.

Found Issue.
30 chaaaaaaaaaaaaaaaaaaaaars

2 Likes