Question about how to prevent exploiters with my script

So my GUI:

I have a mission popup GUI. With an accept and decline button. If the mission is accepted, then I check if the mission can be accepted (I have a max limit of 3 missions at a time)

So originally I did this all via LocalScript, but I kinda realized now that I assume hackers can mess with this.

So I upon clicking the button sent a remote event client - server which in the server script checks if the mission can be done. And then I also was going to do all the GUI code there. But I guess GUI’s can’t be altered on a server script? Since now my script isn’t working.

So I tried to send a server → client event back to the original local script to deal with the GUI changing stuff.

This is my server script

function serverToClient() 
		local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvents").RE3
			remoteEvent:FireClient(true)
end

And then my local script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvents").RE3

local function missionAccepted(status)
if status == true then
print("Can do mission")
end
end
remoteEvent.OnClientEvent:Connect(missionAccepted)

I’m getting this error: Unable to cast value to Object - Server - ServerScript:16

So I guess I can’t just pass a value it has to be an object, in my case I just want to pass a boolean to tell if the mission can be done or not. How would I go about doing this?

The goal is just to make sure that you can do the mission, to avoid hackers. So if there is a better way to do this please help! Thanks.

Hey!

Remote Events are fully capable of doing Boolean values, you just forgot a parameter.

:FireClient() has two parameters. The first one is the player object and the second one is the value to send.

So all you have to do is make:
ReplicatedStorage:WaitForChild("RemoteEvents").RE3remoteEvent:FireClient(true)
this:
ReplicatedStorage:WaitForChild("RemoteEvents").RE3remoteEvent:FireClient(plr, true)

Of course, plr would need to be defined as the player object in which to send the event to.

Hope this helps,
-Robot_Engine

3 Likes

Oh right someone told me that already. Thanks!

No errors, but doesn’t seem to be working. FYI my FireClient (Server → Client) code is inside my server script’s OnServerEvent function. Would this affect it?
server script:


		local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvents").RE3
remoteEvent:FireClient(player, true)

Local script:


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvents").RE3
local function missionAccepted(player, status)
	print("Test")
	if status == true then
		print("Can do mission")
	end
end
remoteEvent.OnClientEvent:Connect(missionAccepted)

Hey again,

In your callback function, the player object is not returned, only the value.

So make it missionAccepted(status)

1 Like

Yep I found that just now thanks.

1 Like