Script does not work in streaming enabled but works in streaming disabled. could anyone help modify this script with WaitForChild and other stuff so it works for streaming enabled? or is their any easy way to do it… since its a code from my old game when games would work better with streaming disabled
local model = script.Parent;
local anchor = Instance.new("Part", workspace);
anchor.Transparency = 1;
anchor.CanCollide = false;
anchor.Anchored = true;
anchor.FormFactor = "Custom";
anchor.Size = Vector3.new(.2, .2, .2);
function cframes(list, base)
local t = {};
for _, part in pairs(list) do
if part:IsA("BasePart") then
t[part] = base:toObjectSpace(part.CFrame);
end
end
return t;
end
function paint(list, name)
for _, part in pairs(list) do
part.BrickColor = BrickColor.new(name);
end
end
function move(cfs, base)
for part, cframe in pairs(cfs) do
part.CFrame = base * cframe;
end
end
local offset = math.random() * 10;
function chord(period)
return (math.cos(offset + tick() * math.pi * 2 / period) + 1) / 2;
end
local head = model:WaitForChild("Head");
local right = model.RightWing.Center;
local left = model.LeftWing.Center;
local body = cframes(model:GetChildren(), head.CFrame);
local rightwing = cframes(model.RightWing:GetChildren(), right.CFrame);
local leftwing = cframes(model.LeftWing:GetChildren(), left.CFrame);
local colors = {
"Br. yellowish orange", "Teal", "Lavender",
"Bright yellow", "Bright bluish green", "Bright red"};
local color = colors[math.random(1, #colors)];
paint(model.RightWing:GetChildren(), color);
paint(model.LeftWing:GetChildren(), color);
function animate()
move(body, head.CFrame);
move(rightwing, right.CFrame);
move(leftwing, left.CFrame);
end
local home = head.Position;
local from = home + Vector3.new(1, 0, 0);
local position = home;
local direction = math.random() * math.pi * 2;
local speed = 4 / 30;
while true do
wait();
local flat, up = Vector3.new(1, 0.1, 1), Vector3.new(0, 0.9, 0);
head.CFrame = CFrame.new(
from * flat + from * up,
(2*from - position)*flat + from * up)
* CFrame.Angles(math.pi/2, 0, 0)
* CFrame.Angles(math.pi * -0.1, 0, 0);
from = position;
position = position + Vector3.new(
math.cos(direction) * speed,
(chord(0.4) - 0.5 + chord(5) + chord(7) - 1) * speed,
math.sin(direction) * speed
);
local distance = (home - position).magnitude;
local power = 1 - math.exp(-distance ^ 2 / 50);
local rd = Vector3.new(-math.sin(direction), 0, math.cos(direction));
local turn = rd:Dot( (home - position).unit ) * power;
direction = direction + (chord(2) + chord(4.123) - 1) / 4 + turn / 10;
--
local h = head.CFrame * CFrame.Angles(math.pi / 2, 0, 0);
local angle = 0.1 + chord(.717/2) * 1 + 0.4 * chord(2.13/2);
local r = 0.2;
local dx = math.cos(angle) * r;
local dy = math.sin(angle) * r;
--
right.CFrame = head.CFrame * CFrame.Angles(-math.pi / 2, 0, 0) * CFrame.new(0, 0, -0.2)
* CFrame.new(-0.04, 0.04, 0)
* CFrame.new(-dx, dy, 0)
* CFrame.Angles(0, 0, -angle)
* CFrame.Angles(0, 0.07, 0)
--
left.CFrame = head.CFrame * CFrame.Angles(-math.pi / 2, 0, 0) * CFrame.new(0, 0, -0.2)
* CFrame.new(0.04, 0.04, 0)
* CFrame.new(dx, dy, 0)
* CFrame.Angles(0, 0, angle)
* CFrame.Angles(0, 0.07, 0)
--
animate();
end