I have created a model that is simply welded together. When the game starts/run, The welded model on the client side appears misaligned and messed up. On the server-side, the model appears normal as it should be.
In the pictures, the left model is anchored with no script interference, and the right model is the welded model.
This is what the server-side Sees:
I have tried starting a local server with 4 client players all seeing the same bugged while the server sees the normal one.
I have also tried restarting Studio but I have no idea what would cause this problem or even a solution to this.
Any help is appreciated Thanks!
This seems to have something to do with the way your weld script is orientating the rope parts, could you provide more information on the location of the weld script as well as snippets of the code to help you debug the issue.
Okay I didnât have a clear look at the code above, but I assume it is probably an issue with some sort of delay in the script.
Here is my foolproof quickWelder that Iâve written years ago, should still work fine and Iâve already published it to the public if anyone wants to take it then Iâll leave a link below.
function createWeld(handle, p)
local weld = Instance.new('Weld')
weld.Part0 = handle
weld.Part1 = p
local c = CFrame.new(handle.Position)
local c0 = handle.CFrame:Inverse()*c
local c1 = p.CFrame:Inverse()*c
weld.C0 = c0
weld.C1 = c1
weld.Parent = p
end
for _, p in pairs(script.Parent:GetChildren()) do
if p:IsA('BasePart') or p:IsA('Part') and p.Name ~= 'handle' then
createWeld(script.Parent.Handle, p) -- Replace script.Parent.Handle with any other primarypart and put this inside a model that you want to weld
p.Anchored = false
end
end
script.Parent.Handle.Anchored = false
I think I may have gotten deleted while I tried to indent it sorry, but here it is again:
âââ
local cannon = script.Parent
local primarypart = cannon.PrimaryPart
primarypart.Anchored = true
local parts = cannon:GetChildren() for i = 1, #parts do
if parts[i]:IsA(âBasePartâ) then
local weld = Instance.new(âWeldâ)
weld.Part0 = primarypart
weld.Part1 = parts[i]
weld.C0 = primarypart.CFrame:inverse()
weld.C1 = parts[i].CFrame:inverse()
weld.Parent = primarypart
end
end
for i = 1, #parts do
if parts[i]:IsA(âBasePartâ) then
local weld = Instance.new(âWeldâ)
parts[i].Anchored = false
primarypart.Anchored = false
end
end
âââ
âââ
function createWeld(handle, p)
local weld = Instance.new(âWeldâ)
weld.Part0 = handle
weld.Part1 = p
local c = CFrame.new(handle.Position)
local c0 = handle.CFrame:Inverse()*c
print(p)âPrinted nil
local c1 = p.CFrame:Inverse()*c
weld.C0 = c0
weld.C1 = c1
weld.Parent = p
end
for _, p in pairs(script.Parent:GetChildren()) do
print(p)âPrinted Part
if p:IsA(âBasePartâ) or p:IsA(âPartâ) or p:IsA(âMeshPartâ) and p.Name ~= âhandleâ then
createWeld(script.Parent.Base)
p.Anchored = false
end
end
script.Parent.Handle.Anchored = false
âââ
But it errored:
[10:32:00.153 - Workspace.Displays.Cannon1t.Weldt:7: attempt to index local âpâ (a nil value)]
10:32:00.154 - Stack Begin
[10:32:00.154 - Script âWorkspace.Displays.Cannon1t.Weldtâ, Line 7 - global createWeld]
[10:32:00.155 - Script âWorkspace.Displays.Cannon1t.Weldtâ, Line 16]
10:32:00.155 - Stack End
I think the Variable P is passed along to the upper function
It is a good practice whenever you are modifying a part to ensure that it is anchored to prevent it from being offset or misaligned while it is moved. Either way happy to help!
Please format your code in a code block using ```lua. Make sure to indent so others can understand it easier too.
--Like this example code:
script.Parent.CanCollide = false
local Block = script.Parent
while Block.CanCollide = false do
Block.Transparency = 0.5
else
warn("CanCollide is set to true.")