Unable to pass object from server to client

I’m unable to pass an object in the workspace from server → client. I don’t understand why, as the object isn’t being destroyed.

If the object is in both the server and the client then you can pass the object as a parameter without it equaling nil

And I think you should be able to pass the tween info in a table and load/create it from there on the server-side

I’m getting this:


As you can see everything prints fine on the server, but on the client it’s nil.

Client code:

local ts = game:GetService("TweenService")

game:GetService("ReplicatedStorage").Tween.OnClientEvent:Connect(function(info,object,goal)
	local targetTween = ts:Create(object,info,goal)
	targetTween:Play()
end)

Server:

local info = TweenInfo.new(targetTime)
local targetGoal = {}
targetGoal.Size = Vector3.new(.7,11,11)
print(info,target,targetGoal)
tween:FireAllClients(info,target,targetGoal)

I’ve made the TweenInfo be created on the client, so that works fine. However, the object still shows up as nil even though it still exists. Help?

@Hydrollo are you sure that an object can be passed from server and client? It’s not working for me. The object is a clone of something in ReplicatedStorage, and it is moved to a folder in the workspace.

Still don’t understand why the object is nil.
Code:

local target = rs:WaitForChild("KillRing"):Clone()
tween:FireAllClients(info,target,targetGoal)

maybe try sending the obj name (make it unique) and then on client just find that child from the name

1 Like

The problem is there are multiple copies of the object (target) being made at once. I found something that was deleting the objects, however it was delayed:

tween:FireAllClients(info,target,targetGoal)
shake:FireAllClients(2.5)
spawn(function()
	animationRun()
end)
debris:AddItem(target,killRingTime-.1) -- this is waiting for 3.9 seconds
wait(ringDelay)

wait where are you storing these copies of the object

Argument 2 missing or nil means the second argument has a issue. Do this code to check it’s not just me being goofy:

Print(object)

I fixed that bug - this is the new error:
image

1 Like

The objects are in a folder in the workspace and are being cloned from the ReplicatedStorage.

Edit: I may have found the issue. The object is being parented too slowly.

replace WaitForChild with FindFirstChild see if that works

Sometimes Waitforchild will return an infinite yield which in return would result in a nil return

Found the issue, there was a line of code that was delaying the set parent. Thanks for your help anyways!

2 Likes

Sometimes Waitforchild will return an infinite yield which in return would result in a nil return

It will only return nil if the timeOut parameter is included and it didn’t find the child with the given time.

If a call to this function exceeds 5 seconds without returning, and no timeOut parameter has been specified, a warning will be printed to the output that the thread may yield indefinitely; this warning takes the form Infinite yield possible on 'X:WaitForChild("Y")' , where X is the parent name and Y is the child object name.
https://developer.roblox.com/en-us/api-reference/function/Instance/WaitForChild

that is what i meant by that
Char limit

1 Like

Misunderstanding something happens too often, I cleared it up so others in the future can understand exactly what you were referring to and what it means, in detail.

2 Likes