How to weld a local part to a server part

Hello there!
I ve been trying to weld a part, that is cloned from a localscript, to a server part but I m not sure if its possible and I need to weld them together since it will be moving (think of it like a car that i need to weld a local part to) here is my local script located in StarterPlayer which does not work:

local car = game.Workspace.car
local part = script.part
local clone = part:Clone()
clone.Parent = game.Workspace.car
local weld = Instance.new("WeldConstraint")
weld.Parent = car
weld.Part0 = car
weld.Part1 = part

I need the part to be local since it will detect if it touches certain objects which are also rendered locally.
Any ideas? Thanks for your time!

You never weld the local part clone to anything.
You are only welding beam and ufo.BeamPart

1 Like

sorry for the messed up code i edited it

1 Like

oh its still not fixed the parts will not weld but thanks for your answer!

The way welds work is that all of the connected parts have to have the same network owner, so a part owned by the server welded to a part that doesn’t even exist on the server wont end well

I don’t think I’ve ever said more times in a day, “just put it on the client” which is kinda funny but I’d say just put it on the client
Roblox automatically will send off physics calculations to clients anyways when they’re close enough so there’s not all that much security increase
You can always check for suspicious flying vehicles or teleporting on the server anyways

1 Like

Oh sorry, my mistake.

Are there any errors with the script? Can you send a picture of the output window?

Also, another issue i’ve noticed is you’re welding the part instead of the cloned part, clone.
You also might want to do script:WaitForChild("part") in case the part isnt loaded yet when you try to access it from the script.

Does this code work for you:

local car = game.Workspace.car
local part = script:WaitForChild("part")

local clone = part:Clone()
clone.Parent = game.Workspace.car

local weld = Instance.new("WeldConstraint")
weld.Parent = car
weld.Part0 = car
weld.Part1 = clone
1 Like

hi thanks for your answer really informative! Although if i put the vehicle in the client how would other players see it?

If you set the network owner of the vehicle to the player that’s driving the vehicle roblox will handle that for you as long as the vehicle model itself was created on the server

You can do this by using part:SetNetworkOwner(player)
I’m not sure if you have to use it on every part or just one, I’d try both methods to see which works, or someone who knows more about it than me can reply

1 Like

Oh thank you so much this worked! I was indeed welding the wrong parts! Thank you!!!

1 Like