What's wrong with this anti-theft script?

  1. What do you want to achieve?

I am currently testing a system I am creating, and I am trying to kick the player if the creator of the game is not me.

  1. What is the issue?

I’m a beginner scripter, so I probably made some sort of obvious mistake for you pros out there. The issue is that it’s not doing anything. It’s a LocalScript inside of the baseplate. This needs to be run on the client because I am trying to kick people if the creator of the game is different than me. I am doing this so if a model is stolen from my game, the script will be stolen as well and will break the thieves game.

  1. What solutions have you tried so far?

I’m stumped, I don’t know what to try. Like I said, I’m a beginner. Here’s my script.

local WeldModel

WeldModel = 000000


if game.CreatorID ~= WeldModel then
	game.Players.LocalPlayer:Kick()
end

Don’t ask why the variable is named WeldModel.

1 Like

LocalScripts don’t run on workspace, consider changing its location to StarterPlayer > StarterPlayerScripts

image

Also, you spelled CreatorId wrong:

if game.CreatorId ~= WeldModel then
	game.Players.LocalPlayer:Kick()
end
1 Like

I’m guessing it is working but the if statement is not being met.

You should be comparing the players UserId with the CreatorId, otherwise it will just kick everyone (if the WeldModel variable isn’t the same). Also keep in mind that if this is a group game the creatorId will return the groupsId and not the group owners userId.

local Player = game.Players.LocalPlayer

if game.CreatorID ~= Player.UserId then
	Player:Kick()
end

I also recommend you do this on the server using the same method but with the PlayerAdded connection.

-May be typos because I’m on mobile-

Actually the API has the perfect example that you can use! Just change it from == to ~= and kick the players.

https://developer.roblox.com/en-us/api-reference/property/DataModel/CreatorId

I should have been clearer. This needs to be run on the client because I am trying to kick people if the creator of the game is different than me. I am doing this so if a model is stolen from my game, the script will be stolen as well and will break the thieves game. I edited my post to make this clearer.

No I didn’t.

This is not something you want to do on the client because that would mean you are trusting the CLIENT, never trust the client (exploits can just stop it from running). You don’t even need a script to keep all but you out, just make the game private. You can still join, but noone else can!

Forgot to mention that code inside of scripts can’t be accessed by players, if someone steals your model it won’t include the script. Even if this was false, they could just remove the script.

You didn’t read the whole post.

I did! Read the edit (Had to be 30 ch)

Maybe use OnCharacterAdded() so the game will check if the player who joined is the creator of the game. If he is, then the game would check his UserId and if his UserId is not the inserted Id, then the game would kick him.

You don’t even need a script to keep all but you out, just make the game private. You can still join, but noone else can!

If you want to keep everyone except yourself out of the game you can just make the game private instead

if you are talking about a whitelist then it’s another story!

I thought exploiters could steal local scripts.

I was planning on hiding it just like creators of malicious assets hide virus scripts.

That is true, but the only reason virus scripts work is because people choose not to look through what they add to their own game, it’s well known that you should check freemodels. And if it saved a script that script could just be deleted in studio or even in the exploit itself.

(And note that trying to kick players inside of a localscript is not recommended because of the fact that localscripts run on the player, an exploit could easily stop the localscript from running at all)

This one will be hidden better. The hiding is still in the works.

You cant just hide it. If it is saved on the exploiters computer they can literally just delete it, even without studio. You should prevent the player from ever accessing it in the first place.

But again, why don’t you just make the game private if you don’t want anyone but you accessing it?

The problem with your script is that you’re writing it at all. It took me some time to find your exact use case for doing this and it’s not a strong use case. See:

While this response I gave has to do with whitelisting goods to sell to other developers, the same is likewise applicable for you attempting to close others’ instances down if they use a model of yours. Not viable from the server-side because server bytecode isn’t sent to the client and not viable from the client either because they can see and delete your code.

I recognise this isn’t a direct solution but it’s instead addressing the underlying problem that you’re doing something highly unnecessary and easily bypassable. World geometry is simply not safe from theft and Roblox places are as secure as possible. There’s no reason to add code that won’t help you actually stop the issue you’re concerned about.

Only realistic way around this is, as said above, making your game private. Some showcase games do this and instead post images to a social media account or similar if they want to show their creation.

1 Like

Here you go, tbh you could’ve just privated the game.

local allowed = {}
game.Players.PlayedAdded:Connect(function(player)
if not table.find(allowed,player.UserId) then player:Kick("come back later.") 
end
end)

Also not tested as I’m not on pc.

On roblox for now there isn’t a real option for something like this yet, sadly. Would make for a good feature request, i believe it’s already been requested so just bump those!

I cant get the correct syntax and layout on phone, my bad.

Apologies for misinformation said in the title. My script is not a whitelist script, an editor changed my title to something that did not describe my issue. I have edited the title.

local WeldModel = 000000

if game.CreatorId ~= WeldModel then
 game:GetService("Players").PlayerAdded:Connect(function(plr)
  plr:Kick()
 end
end

Sorry for the late answer xD
This is a Script, not a LocalScript, you can put it in the Workspace or in the ServerScriptService as I understand.