RemoteFunctions just don't work now?

I have just yet come accross the issue that, Remotefunctions just don’t work. Simple as that.

I even used the source code from Roblox Api engine. Is it just me, or my computer, or my studio?

I would really appreciate if someone would test this code out and tell me if it works for you

Check 1 prints, but check 2 doesn’t and the server doesn’t print anything aswell

Client

local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Get reference to remote function instance
local remoteFunction = ReplicatedStorage:FindFirstChildOfClass("RemoteFunction")

-- Pass a color and position when invoking the callback
print("Check 1")
local newPart = remoteFunction:InvokeServer(Color3.fromRGB(255, 0, 0), Vector3.new(0, 0, -20))
print("Check 2")
-- Output the returned part reference
print("The server created the requested part:", newPart)

server:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Get reference to remote function instance
local remoteFunction = ReplicatedStorage:FindFirstChildOfClass("RemoteFunction")

-- Callback function
local function createPart(player, partColor, partPosition)
    print("Client fired RemoteFunction")
	print(player.Name .. " requested a new part")
	local newPart = Instance.new("Part")
	newPart.Color = partColor
	newPart.Position = partPosition
	newPart.Parent = workspace
	return newPart
end

-- Set function as remote function's callback
remoteFunction.OnServerInvoke = createPart
1 Like

I would strongly recommend not using FindFirstChildOfClass here. The questions is, are the children of ReplicatedStorage ordered? And even if they are, are they ordered the same on server and client?

I’m guessing your remoteFunction is simply not referencing the function you think it is.

To confirm whether or not this is the issue, just use a named function like:
local CreatePartFn = ReplicatedStorage:WaitForChild("CreatePartFn")

Then you’ll at least have confidence that you’ve eliminated one possible problem.

Lastly, not what you asked about, but I don’t think you can serialize part instances across remote functions/events like that anyway. And I’m not sure why you’d want to but that’s a separate issue.

1 Like

That isn’t the issue, and this is the example code from the api engine reference btw. The problem was that I put the script in serverstorage instead of serverscriptstorage XD

1 Like

Mark your reply as a solution, so the other people can see that this problem is solved.

2 Likes

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