Hello, I am making a top donator statue, but I am having a problem, whenever the script updates the statue, it’s a lag between updating. Here’s a video:
robloxapp-20201111-0344005.wmv (192.9 KB)
Here’s my code:
local success, errormessage = pcall(function()
local pages = datastoreservice:GetSortedAsync(false, 1);
for i, v in pairs(pages:GetCurrentPage()) do
local userid = tonumber(v.key)
local name = Players:GetNameFromUserIdAsync(userid)
workspace.Updater.SurfaceGui.plrName.Text = "Name: " .. name;
workspace.Updater.SurfaceGui.Donation.Text = "Donation: " .. tonumber(v.value);
local newDummy = game.ReplicatedStorage.Dummy:Clone();
local description = Players:GetHumanoidDescriptionFromUserId(userid)
local humanoid = newDummy:FindFirstChild("Humanoid")
if humanoid ~= nil and (workspace.Statues:FindFirstChildOfClass("Model") == nil) then
newDummy.Parent = game.Workspace:FindFirstChild("Statues")
humanoid:ApplyDescription(description)
for i, o in pairs(newDummy:GetChildren()) do
if o:IsA("BasePart") or o:IsA("Decal") then
o.Transparency = 1;
end
end
newDummy:SetPrimaryPartCFrame(CFrame.new(Vector3.new(workspace.Part.CFrame.Position.X, workspace.Part.Position.Y + workspace.Part.Size.Y/2, workspace.Part.Position.Z)) * CFrame.Angles(0, math.rad(180), 0))
humanoid:ClearAllChildren()
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
for a, b in pairs(game:GetService("ServerStorage").Elements:GetChildren()) do
if b then
b:Clone().Parent = humanoid
end
end
humanoid:LoadAnimation(newDummy["Hand Up"]):Play()
wait(0.5)
for i, o in pairs(newDummy:GetChildren()) do
if o:IsA("BasePart") or o:IsA("Decal") and (o.Name ~= "HumanoidRootPart") then
o.Transparency = 0;
end
end
newDummy.HumanoidRootPart.Transparency = 1;
break
end
end
end)
if success then
else
print("An error occured.. " .. errormessage)
end
Help is appreciated!