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 return a part in remote function it keeps saying its a nil value and i cant do anything?

local RemoteFunction = game.ReplicatedStorage.RemoteFunction


RemoteFunction.OnServerInvoke = function(Player)
	 return game.ServerStorage.Part:Clone()
end	

there are no errors but

What If I wanted to turn the part red or do things with it

when I do

RemoteFunction:InvokeServer().Parent = workspace in a local script it wont work

saying its a nil value when i returned something

how would I return a part through remote function

1 answer

The part is still in serverstorage when you cloned it, and the client can't access serverstorage, so you might want to parent the part to workspace or something before returning it back to the client

local RemoteFunction = game.ReplicatedStorage.RemoteFunction


RemoteFunction.OnServerInvoke = function(Player)
	local part = game.ServerStorage.Part:Clone()
	part.Parent = workspace
     return part
end 

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