Ad
Log in to vote
1

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

Asked by 11 months 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)

0
make the part on the server abnotaddable 862 — 11mo

1 answer

Log in to vote
0
Answered by 11 months ago
Edited 11 months 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 = Instance.new("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
end)

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
end
0
This is an example of non repliacted instances. Always make the part on the server. abnotaddable 862 — 11mo
Ad

Answer this question