Having trouble with RemoteFunctions

I’m wanting to have a remotefunction that returns a boolean.
this error is in the output:


and here is the localScript that may be causing it

local event = game.ReplicatedStorage.RequestPrompt
local Donator = game.ReplicatedStorage.Donators.RequestBase
local Frame = script.Parent
local plr = game.Players.LocalPlayer

event.OnClientInvoke:Connect(function(plr2)
	local Return = nil
	local clone = Donator:Clone()
	clone.Parent = Frame
	clone.PlayerLabel.Text = plr2 .." Party Up?"
	local Accept = clone.Accept
	local Decline = clone.Decline
	Accept.Activated:Connect(function()
		Return = true
		clone:Destroy()
	end)
	Decline.Activated:Connect(function()
		Return = false
		clone:Destroy()
	end)
	clone.Destroying:Connect(function()
		return Return
	end)
end)

try:

event.OnClientInvoke = function(plr2)

instead of:

event.OnClientInvoke:Connect(function(plr2)
1 Like

It fixed the error, but it always returns as nothing. anyway to fix that?

do the return like here and get rid of the destroying part

Accept.Activated:Connect(function()
	Return = true
        return Return
	clone:Destroy()
end)

(maybe, u might wanna check if everything is activating too)

it seems to have this error:

show a ss of the latest code so I can see where you are missing a end

You have a line of code after the return:

return Return
	clone:Destroy()

The clone:Destroy() call will never run as the function will return before it.

how would i get the instance to destroy then?

I don’t know what you are talking about rn because I don’t have an idea of what the script looks like

try instead of function accept() do local function accept() and same with the other one

that changed nothing @gamincwc

what is Accept, a gui button? oh and also you don’t need the Return variable

what? is there another way to get a bool from the remotefunction?

the Accept I assume is a button so try instead of .Activated do .MouseButton1Clicked
.Activated is not even used that much as it is a property and not an event

I fixed it by putting clone:destroy() before return and i added

repeat wait() until Return ~= nil
	return Return

to the end of the OnClientInvoke event.

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