Log in to vote

Fe: create part on client, let server parent it to workspace?

Asked by 4 days ago

Hello everyone!

I'm trying to convert a game to FE but it has a complicated placement system. It clones a part and then places it. But when you place it, only the player that placed it can see it.

I wanted to solve this by creating a thing when the event gets fired, it contains the created part as a parameter. Then the server will parent the provided part to workspace. But it always says "Atempt to index local 'part': a nil value".

I'm sure that my script is right because i've seen some other people having the same problem: not being able to pass instances though remoteEvents. I've also tried parenting it to a folder in replicatedStorage but it looks like the server can't see what the client putted in replicated storage.... T

hen i thought "Hey! A server and a client can read the leaderstats, so maybe i'm able to put an objectValue in there with a link to the created part. Wrong. The server can see that there is a leaderstat but it can't see the value if a client changed it....

So my question: How will i be able to pass a client sided created part to the server?

print("Thanks for your time and help")

Jonas (marketmanager1)

make the part on the server abnotaddable 712 — 4d


Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.




Now back to your regularly scheduled Scripting Helpers....




1 answer

Log in to vote
Answered by 4 days ago
Edited 4 days ago

First of all, when you’re creating a part on the client then replicating it to the server you’ll need a local script and a script. The script should be placed in ServerScriptService and put the localscript wheere you need it to go.

If I make mistakes it because I’m typing fast

Roblox Wiki on remote events and functions

In the Script:

local RemoEv ="RemoteEvent") -- Allow us to communicate between the server and the client
RemoEv.Name = "PartTransfer_$001" -- A complicated name makes it harder for people to bypass Filtering.
RemoEv.Parent = game:GetService("ReplicatedStorage") -- Put the RemoteEvent somewhere

RemoEv.OnServerEvent:connect(function(player, part) -- When the localscript asks this script to make the part
    part:Clone().Parent = game.Workspace -- Put the part in the workspace or wherever u want

In the local script:

local PT1 = game:GetService("ReplicatedStorage"):WaitForChild("PartTransfer_$001") -- Find the Remote Event

function sendPart(part) -- Run this to send a part to the server so it can replicate
    PT1:FireServer(part) -- Tell the server to make the part
This is an example of non repliacted instances. Always make the part on the server. abnotaddable 712 — 4d

Answer this question