Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I return a part in remote function it keeps saying its a nil value and i cant do anything?

Asked by 4 years ago
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

Log in to vote
0
Answered by 4 years ago

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 

Ad

Answer this question