RemoteFunction returns part, but client prints it out as nil

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to create a working VR hand script. It works in another game, but not in the game i am currently working on. I’m using the same code, remote events and remote functions.

  2. What is the issue? Include screenshots / videos if possible!
    As the title says, the remote function does return a part, but the client prints it out as nil

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!


local lefthand = VR.create:InvokeServer(character,head,"Left Arm") :: Part
local righthand = VR.create:InvokeServer(character,head,"Right Arm") :: Part
print(lefthand) -- retunrs nil
print(righthand) -- returns nil


local function createHand(plr,character : Model,head : Part,handType : string)
    local hand ="Part")
    hand.Parent = character
    hand.CFrame = character.HumanoidRootPart.CFrame
    hand.Size =, 2, 1)
    hand.Color = head.Color
    hand.Transparency = 0
    hand.CanCollide = false
    hand.Anchored = true
    hand.Name = handType
    warn(hand) -- retunrs actual name of hand
    local g ="WeldConstraint")
    g.Part0 = hand
    g.Part1 = character.HumanoidRootPart
    local deb = true

        if deb then
            warn("tocuhed", p)
            if p.Name == "Right Arm" or p.Name == "Left Arm" then
                deb = false
                local clap ="Sound")
                clap.Parent = head
                clap.SoundId = "rbxassetid://2704706975"
                clap.Volume = 1
                deb = true
    return hand
game.ReplicatedStorage.VR.create.OnServerInvoke = createHand

I am very confused by this, and help would be VERY appreciated.

I don’t think you can send instances through iirc

If it’s client only then make the hand on the client, if you would like it to replicated to others then maybe make it on the server and give network ownership to the player

What seems to be the problem is that the hand is not yet replicated to the client. You return less than micro seconds after the parent property is set, and it takes a short while (one way latency) for the object to be created in the client’s version of the game too.

Reference cannot be passed because the part doesn’t exist locally yet, and remotes only pass instances that exist on both computers. That’s why you can never send objects from ServerStorage, for example.

You will have to wait a bit. I reproduced your code and task.wait(1) solved it.

Because latencies vary, this is not the neatest practice, we can alternatively pass the name of the hand and have the player use :WaitForChild(given_name) while knowing where the hand is going to appear, meaning, for instance,

local rHandName = VR.create:InvokeServer(character,head,"Right Arm") :: string
local rightHand = character:WaitForChild(rHandName)

This also leads to the question whether remote events are more suitable than remote functions in this case.

VR.Create:FireServer(character, head, "Right Arm")
local rightHand = character:WaitForChild("Right Arm")
--> already know the name and location

I am not currently home. When I will, i’ll make sure to try your solution out.

1 Like

When attempting to get a part from client to server, the server does not know what is being created on the client. It’s best to try to replicate what is done on the client to the server, I’m pretty sure RemoteFunction can only pass through data when attempting to do client to server.

I used the event way, it normally did create the parts, but another event (the hand moving function on the server) claims that it is nil

That’s alright. We should be past the original problem now.

As for this hand moving function on the server, would you mind sharing some problematic parts of the code? How is the hand moving function accessing the hand? At this point both the server and the client can access the hands in the character.

I just got the thing working. I first off did the character:WaitForChild(“Left Arm”), etc. I then got the idea to do the same concept with the hand moving code on the server. In the client, it fires the event to the server, with the hand, the camera cframe and the cframe offset of the controllers.
The only thing I changed in the server code is so it checks the player’s character for the hand, as it was created on the server, now it works just how it’s supposed to.

1 Like

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