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!
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
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
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