Confirm Part Sent Through Remote Actually Exists On Server

I am sending mouse.Target through a Remote (when the player clicks on a specific part within a group).

I know how to confirm that the mouse.Target is a BasePart, but how do I confirm that the mouse.Target actually exists on the Server?

I don’t want exploiters sending false mouse.Targets (from fake parts) to trip up the Server script.

I tried using FindFirstChild(MouseTarget) but it doesn’t work because FindFirstChild wants a String.

I cannot convert the Instance to a string because every Instance in the folder has the same name.

1 Like

Here is an example of what I mean.

CLIENT:

script.Parent.RemoteEvent:FireServer(mouse.Target, mouse.TargetSurface)

SERVER:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, target, targetSurface)
	if not target:IsA("BasePart") then warn("Not A BasePart") return end
	— need to check if part really exists on the server
end)

No. if you create part on client and send it over remote server will tell nil

EDIT: check if part exist and if not return, you should be fine then

1 Like

just check if target then, because if it doesn’t exist server sided then it’ll return nil if it does it should return true

1 Like

Thanks @0786ideal and @sfgij !

You are both right.

I totally forgot I could test cloning a block on the client in Studio.

The line if not target:IsA("BasePart") then warn("Not A BasePart") return end takes care of it since the item is nil.

I didn’t know it would be nil.

I don’t reccomend using warn, simplu return, it may cause exploiters to spam print your output, also you don’t need to check if it’s basePart but rather if it exist

if not part then return end

Thanks, I had not thought about spamming the output.

Those exploiters will do anything to mess up a game!

:face_with_raised_eyebrow:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.