Remote event is sending nil value UNLESS I use a task.wait

game.ReplicatedStorage.Wormhole.OnServerEvent:Connect(function(player,to:Vector3,from:Vector3,duration:number)
	local worm = CreateWarp(to,from,duration)
	worm = workspace:WaitForChild(worm.Name)
	game.ReplicatedStorage.Wormhole:FireClient(player,worm)
end)

So this code does stuff to make a union serversided (I have to make unions in a server script idk why)
The worm = workspace:WaitForChild(worm.Name) is to try to make it not return nil.
Funny thing is, if I print the union, or the unions parent in the server script, everything prints fine.
It exists.
But if I print it in the local script, -

game.ReplicatedStorage.Wormhole.OnClientEvent:Once(function(wormhole)
	print(wormhole)
end)

-then it prints nil.
UNLESS I ADD A TASK.WAIT, Bruuuh.

I don’t know why the local script keeps complaining that the union doesn’t exist, when I CAN LITERALLY SEE IT IN FRONT OF MY EYES, and the server script says that it exists, because it does.

1 Like

Maybe try sending the worm.Name to the client and then determine the union with workspace:WaitForChild(worm.Name) on the client.

That’s what I just did which has seemed to work, buuuut, what if for any reason there are multiple unions in the workspace with the same name? The local script would get confused. But then again it somewhat works.

Not sure how your wormhole’s naming scheme works but if assuming a player can only use 1 wormhole at a time you could make the part name their user id or something irreproducible.

1 Like

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