Remote event or function question

I’ve been trying all day to get this right and keep failing.

I have a GUI with a button. I only want the button to run code (if conditions are met) I also don’t want any hackers manipulating the local scripts.

So at first, I tried doing a client → server event and in the server script I checked if the conditions were met. And then I needed to do GUI changes. So inside that ‘OnServerEvent’

I then sent a server → client event back to the original local script and here inside the ‘OnClientEvent’ function I then want to start doing the GUI changes. But when I try to do the server → client it doesn’t seem to be working. Is it because you can’t send server → client inside of a function that’s being called on ‘OnServerEvent’ ?

Is there a better way to do this? This is my code:
Local Script: Client → Server

local frame = script.Parent
frame:WaitForChild("Accept").MouseButton1Down:Connect(function(Accept)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvents").RE2
		remoteEvent:FireServer("MissionName")
end)

Server script:

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

game.ReplicatedStorage:WaitForChild("RemoteEvents").RE2.OnServerEvent:Connect(function(player,missionName)
local MissionValues = player.PlayerGui:WaitForChild("MissionValues")
if (MissionValues.CurrentMissions.Value < 3) then
remoteEvent:FireClient(player, true)
end
end)

So now inside this function I then fire back from the Server → Client

Local script:

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

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

This function doesn’t run ^ Any ideas? What’s wrong, or how to do it better?

I’d suggest putting more prints around your code such as whenever you connect a function or complete an if statement, then tell us your results.

First of all, the chance of your game getting hacked is <1%.

So this part

print("fire event")
remoteEvent:FireClient(player, true)

It prints ‘fire event’

but the client function doesn’t run at all. I have prints inside it, nothing is outputted.

Why is that?
///////////////////

Are you connecting with the right remote event?

Edit: I know what’s the issue I just realized I’m removing this local script once the client → server runs. So when the server tries to go back to the client, the script is gone. Thanks.

New question though
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")
		frame.Parent:Remove()
	end
end
remoteEvent.OnClientEvent:Connect(missionAccepted)

So “test” is being outputted, but status doesn’t seem to be equal to true, any idea why that is? Is my argument set up wrong?

I just tested and status is = to nil

try this?

local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

remoteEvent.OnClientEvent:Connect(function(player,status)
	print("Test")
	if status == true then
		print("Can do mission")
		frame.Parent:Remove()
	end
end)

Just a small change I wanna see if it makes a difference.

I found the issue the receiving end (server → client) does not need player in it’s first parameter. So in this case because I put (player, status) it was assuming player was the boolean.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

local function missionAccepted(player, status)
	print("Test", status)
	if status == true then
		print("Can do mission")
		frame.Parent:Remove()
	end
end
remoteEvent.OnClientEvent:Connect(missionAccepted)

should of been:

local function missionAccepted(status)