LocalPlayer on Server

I have a LocalScript that uses :Destroy() on a block when it is touched by the LocalPlayer, so that nobody else will see it happen until they have touched it themselves.

There is a CFrame animation that plays before it gets destroyed, which is why I want to use ServerScripts instead to prevent hackers from being able to gain access to my scripts.

while true do
	wait();
	if game.Players.LocalPlayer then
		break;
	end;
end;
local l__LocalPlayer__1 = game.Players.LocalPlayer;
local v2 = game.Workspace.CheckSpawns;
local v3 = true;
for v4, v5 in pairs(v2:GetChildren()) do
	local u1 = v3;
	v5.Touched:Connect(function(p1)
		if p1.Parent == l__LocalPlayer__1.Character and u1 then
			u1 = false;

So I was just wondering if there was any way to make it work the same but on the server, using RemoteEvents if truly necessary. To lower the chances of somebody gaining access, as low as physically possible.

4 Likes

I’m not sure what your end goal is but if you want to use .Touched on the server and still get the player who touched it just do this,

local CheckSpawns = game.Workspace.CheckSpawns;
local v3 = true;
for Index, Value in pairs(CheckSpawns:GetChildren()) do
	Value.Touched:Connect(function(Hit)
        local Player = Players:GetPlayerFromCharacter(Hit.Parent)
        if Player and v3 then
            u1 = false;
            -- rest of the code here
        end
    end)
end
4 Likes

The end goal is to make it so it will only disappear for the player who touched it.

Just to let you know. That’s worse you’d rather just not want to use RemoteEvent’s if your trying to prevent hackers. Because, if you use remote events they can use those RemoteEvent’s to replicates into the server. So, there is no ultimate way to use RemoteEvent’s in this case. So, either way whatever your trying won’t work. Because remote events can be reversed to do it. But, in the end they can be reversed by a hacker to replicate to the entire server. So, usually you wouldn’t want to use a RemoteEvent if your trying to prevent Hacker’s from hacking it.

2 Likes

So it’s safer to use LocalScripts?

Is there at least any way to obfuscate it, like to the point where it’s unreadable? So then they can’t remove the extra security parts I’ve added to the code?

2 Likes

Well, you could try to make firewalls using other websites, or use HTTP Services. It’s safer to use Local Scripts then Remote Events because if you use Remote Events they can use local scripts to replicate what happens in the Local Script to the entire server. The entire server would be server sided which hits everyone at once. Local Scripts only hit a client aka just one computer, or whoever that does it

3 Likes

If you want to obfuscate it try making it link to other websites. Making it link to other websites would help you drastically because, then you can make firewalls, and all sorts of code that they have no clue you’ve made. Which means it’d be safer if you used another website with roblox both, at the same time.

3 Likes

That seems very hard and time-consuming. Are there any obfuscator apps that I can use, instead? (Roblox plugins don’t obfuscate it enough)

2 Likes

I don’t know for sure. I obfuscate my code, at all you can maybe look up tutorials, or find any on youtube. Because I honestly have no clue if there are, or aren’t.

Can’t the exploiters just read the code and go to the sites? It’s not like only letting me access them will work, because then how will Roblox be able to read it?

2 Likes

By using API Keys. Roblox has created an API Key’s feature that can get to other websites.

Could you link me to a documentation page? I haven’t been in Lua long and barely understand what an ‘API key’ is.

2 Likes

Sure, just give me a few minutes to get one up.

Wouldn’t the exploiters also be able to use API Keys for themselves then just print the line(s) of code they need?

1 Like

Well, if the website is secure enough depending on where you go. They won’t be able to get onto it to disable the security. Here’s the link to the API Key Document: Managing API Keys | Documentation - Roblox Creator Hub.

2 Likes

Do you have any recommended websites that I can use?

1 Like

Well, I do know one website. But, you’d have to create your own custom code to prevent hackers, and all. Because, I don’t know if there’s a tutorial on it. Link: https://console.firebase.google.com/project/fir-demo-project/overview?pli=1. All I know is someone I know used this website to create code to protect their game.

1 Like

Would you also mind writing a short example line of code for what you mean? (for the local script, I mean)

1 Like

local player = game.Players.LocalPlayer
local character = player.Character
local Part = game.Workspace.PartName – Put the part name here.

Part.Touched:Connect(function(hit)
if hit then
if hit.Parent == character then
Part:Destroy()

1 Like

Here’s the entire local script, Without CFrame.

1 Like