How do I send a part from LocalScript to Server?

Hello everyone, so I was wondering if there was a way to send a part made from localscript, to server script so that I can then make that part visible for the entire server. I used RemoteEvents, such as:

makeToWorkspaceEvent:FireServer(v)

Where v is the part I want to send, but it always comes up as nil on the server side. Is there any way I can accomplish this? Thank you. :slight_smile:

1 Like

Why don’t you make the part using the server script instead?

Like the person above said, just make the part server sided, or if that does not work, I suggest showing the code, its not that clear from my perspective.

I can’t because of Settings options that are from localscript and based on the client :confused:

You can send the properties you want via remote and let the server make the part

I just want to set the parent to workspace on the server. Some parts are created differently in the local script so it would be inconvenient since all I want to do is change their parent property…

Can you send the code? I’m a bit confused

Okay, this is the code that calls the event in LocalScript:

makeToWorkspaceEvent:FireServer(v)

And this is what’s on the Server Script that handles events:

function onMakeToWorkspaceEventFired(player, model)

print("Model's name is: " .. model.Name)

model.Parent = workspace

end

makeToWorkspaceEvent.OnServerEvent:Connect(onMakeToWorkspaceEventFired)

And then it returns that “nil” cannot have a parent property. So obviously the part is not being passed through. Anyone know how to get around this? That’s what i’m looking for. Thanks.

You simply can’t parent a part made from the client via the server because the part simply does not exist for the server, only for the client, so you should make the part using the server instead.

Is that the only way? Alright then, I guess I have some work to do. Thanks for the help.

Clients are ran on you’re computer and you have full access to edit roblox files and create a new localpart.
So the client can be shady. also the 2nd reason is because when a client makes a part. It isnt sent to the server, because some localparts are used for client animations or are oy for the client to see.

The server needs to create parts because so it can be replicated across all clients. and not just one, the bad idea is letting a client replicate them all. like I said in the first paragraph you can edit roblox files on your computer but you cannot edit the server.

Solution

  1. using the RemoteEvent send the server all the properties of the part
  2. create a function on a ServerScript that knows how to create the part without all the properties the client sent. (This is good because the client can send the size of the part to be really huge or worse.) and so that the client can send in less data.