Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix this Remote Function error?

Another simple question, I know. I'm a noob at Roblox Studio. So, I'm trying to use a Remote Function to get one Local Script to tell another Local Script to make a gui appear, which should be a simple task, but I guess I'm doing something wrong. It gives me an error code whenever I try to achieve this. What am I doing wrong?

Error Code: 15:36:52.249 - OnClientInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available 15:36:52.250 - Stack Begin 15:36:52.251 - Script 'Players.EnderGamer358.PlayerGui.StartGui.Coverup.Sequencing', Line 33 15:36:52.251 - Stack End

I am doing the communication through two Local Scripts, here is the code I'm using:

Script that's sending the signal:

P.MouseButton1Click:connect(function()
	for i=1, 10 do
		wait(0.05)
		S.ImageTransparency = S.ImageTransparency + 0.05
		T.ImageTransparency = T.ImageTransparency + 0.05
	end
	local G = P.Parent.Parent.Parent:WaitForChild('StartGui')
	G.Coverup.Sequencing.CoverupFunc:InvokeClient()
	for i=1, 10 do
		wait(0.05)
		S.ImageTransparency = S.ImageTransparency + 0.05
		T.ImageTransparency = T.ImageTransparency + 0.05
	end
	P.Parent.Visible = false
end)

Script that's receiving and acting on the signal:

script.CoverupFunc.OnClientInvoke:connect(function()
	P.Visible = true
	P.BackgroundTransparency = 1
	for i=1, 20 do
		wait(0.04)
		P.BackgroundTransparency = P.BackgroundTransparency - 0.05
	end
	workspace.CurrentCamera.CFrame = CFrame.new(207, 103, -112)
	for i=1, 20 do
		wait(0.04)
		P.BackgroundTransparency = P.BackgroundTransparency + 0.05
	end
end)

1 comment

1 answer

###Callbacks and Events

The problem here is a simple one. You're attempting to set OnClientInvoke as an event, not a callback, like it is required to be. A callback is a type of event that is called whenever an event runs.

OnClientInvoke and OnServerInvoke both require a callback. The correct syntax for this is:

RemoteFunction.OnClientInvoke = function

###connect vs Connect

connect has been deprecated and should not be used. Instead, use Connect.

###Solution

local function coverMain()
    P.Visible = true
    P.BackgroundTransparency = 1
    for i=1, 20 do
        wait(0.04)
        P.BackgroundTransparency = P.BackgroundTransparency - 0.05
    end
    workspace.CurrentCamera.CFrame = CFrame.new(207, 103, -112)
    for i=1, 20 do
        wait(0.04)
        P.BackgroundTransparency = P.BackgroundTransparency + 0.05
    end
end

script.CoverupFunc.OnClientInvoke = coverMain

2 comments

0

Thank you for your suggestion, and I'm pretty sure it'll work, but it's giving me another error code, possibly due to another error in the script. It says "Argument 1 is missing or nil", and the error is in the script that's sending the signal, Line 8.

0

the new error could be because CFrames don't just have 3 vectors they have TWELVE (wow)

This discussion is preserved as it was. New answers, comments, and votes are closed.