This may be a big chunk to do,but mainly Im simply trying to make my pig walk to different locations while welded together,if you cannot resolve the script I put out,do you have any other methods I could choose?
Error:The pig won't move(at all)
---------------------------------Weld Script
function weld()
local parts,last = {}
local function scan(parent)
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
if (last) then
local w = Instance.new("Weld")
w.Name = ("%s_Weld"):format(v.Name)
w.Part0,w.Part1 = last,v
w.C0 = last.CFrame:inverse()
w.C1 = v.CFrame:inverse()
w.Parent = last
end
last = v
table.insert(parts,v)
end
scan(v)
end
end
scan(script.Parent)
for _,v in pairs(parts) do
v.Anchored = false
end
end
weld()
script:Remove()
----------------------------------CFrame Script
pig = script.Parent
function Walking()
torso = pig.Torso
torso.CFrame = CFrame+Vector3.new(math.random(1,6),0,math.random(1,6))
while true do
print(torso.CFrame)
wait(.5)
end
end
function Alarmed()
pig.Torso.Touched:connect(function(hit)
if hit.Name == "Damager" then
pig.Alarmed.Value = true
wait(10)
end
end)
pig.Alarmed.Value = true
end
while true do
Walking()
wait(1)
end
__________________________________________________________________________
|