Should I put this on the clinet?

Hey, so basically I have a map where players can be arrested when they enter a certain area. When they touch a part, it makes them arrestable or unarrestable. Currently when they touch the part, it is handled locally and fires to the server to make them arrestable or unarrestable. Is this a good idea? I figure if they are able to disable the local script from firing, they would be able to just delete the part from the workspace with btools, right?

Also, the game isn’t going to be extremely popular, so I plan on being able to manage having moderators in a majority of the servers most of the time

1 Like

Depends,

The Client will only replicate to one Player, and not the entire Server, RemoteEvents would just send that data to the Server, though it may be better to handle it on the Server rather than the Client as you can practically do the same thing there.

Only on the Client, what they do themselves on the Client will only effect them. unless they have access the Server

1 Like

Bad idea. The client could just spam fire unarrestable to the server. (if they were using exploits)

2 Likes

I don’t understand why the part touching has to be handled on the client? Seems pretty unnecessary and a pretty easy fix, you should try to prevent exploiting when you can even if you’re going to have moderators, you don’t want to give them a headache.

1 Like

True, but what prevents them from just deleting the part that makes them arrestable? I suppose I could randomly check their position, and if they are in an arrestable area and are’t arrestable, then I could assume they are exploiting.

1 Like

I suppose you could do that but that would just be overcomplicating things, it’s a lot easier to just code all of this on the server.

1 Like

In my opinion, the region of arresting would be best checked using the Vector3 coordinates instead. They could check if they are within a range and loop through ranges for it.

1 Like

But if they delete it on the client, then they wont touch the part because it’s not on the client. If all of it was controlled on the server, then could they delete the part locally and not be registered because the part is gone?

I wasn’t sure if it would help lessen the work on the server

On the Client. yes

But on the Server, Probably not as the change has not occurred there and only to the player

1 Like

You make a good point, but at the same time, games with thousands of kills bricks in obbys have touched events run on the server and still work fine.

1 Like

Yes, the server will have less stress but it isn’t worth it when your entire game could break with a simple exploit.

1 Like

Thats because they make the Server look through itself and Apply Connections, it would be a lot worse if you had a part from every KillBrick with a script, which would slow down the game

1 Like

Would a good idea be (server)

local ArrestableFolder = workspace:WaitForChild("ArrestableParts")
local UnArrestableFolder = workspace:WaitForChild("ArrestableParts")
local Prisoners = game:GetService("Teams")["Prisoners"]

for i,v in pairs(ArrestableFolder:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if Player.Team == Prisoners then
				if Player:WaitForChild("Arrestable").Value == false then
					Player:WaitForChild("Arrestable").Value = true
				end
			end
		end
	end)
end

for i,v in pairs(UnArrestableFolder:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if Player.Team == Prisoners then
				if Player:WaitForChild("Arrestable").Value == true then
					Player:WaitForChild("Arrestable").Value = false
				end
			end
		end
	end)
end

Indeed, that is why I suggested checking it with Vector3 coordinates instead. Have a start point and an end point forming a rectangle and loop through all of your rectangles and check if the player is within them.

1 Like

Why don’t you just do :FindFirstChild arrestable? If they are a police officer, they shouldn’t have that value.

True, I have a police team, a prisoners team and a criminals team, (and neutral when they join the server) but whenever the player joins the server they are given the arrestable value anyways so it doesn’t have to be removed and added back whenever they switch teams, if they sounds better?

I am working within a building, so it’s mainly rooms and spaces that they are in, and every few studs matter, so if I run a loop checking their position every 2 seconds, they might be able to run into a room within those 2 seconds and do something. Not sure if it is easier just having parts control it because they can be more exact, and I heard loops can become laggy on the server so I’m trying to cut down as much

How does the arresting work? Would you be able to check when someone is attempting to arrest someone instead?

1 Like

You could do this:

local params = OverlapParams.new()
params.FilterDescendantsInstances = {}--put every folder in workspace in here so it only focuses on characters

for i, v in pairs(workspace:GetPartsInPart(yourHitBox,params)) do
--all characters in the part will be in here even if they tinkered with the part
end
1 Like