Issue
Hey, i was making a progress bar for a game and had a few errors.
Progress bar btw helps you know the position of yourself and other players on the x axis.
Here the problem that occurred from it.
![]()
As you can see its getting dragged about which makes it very weird.
when i say dragged. it means that the image is getting duplicated that it leaves a trail on every move
local X2 = workspace.MainFolder:WaitForChild("Difficulty999"):WaitForChild("Part1").Position.X
local X1 = workspace.MainFolder:WaitForChild("Difficulty0").PrimaryPart.Position.X
local function GetPosition(X)
return (X-X1)/(X2-X1)
end
local Color = Color3.fromRGB(85, 255, 0)
local function ColorConnection(p,v)
if game.Players:GetPlayerFromCharacter(v.Parent)and game.Players:GetPlayerFromCharacter(v.Parent).UserId == game.Players.LocalPlayer.UserId and string.len(p.Name)>4 and tonumber(string.sub(p.Name,5))then
Color = p.Color
end
end
local function color1(p)
if p:IsA("BasePart")then p.Touched:Connect(function(v)ColorConnection(p,v)end)end
end
local function color2(p)
p.ChildAdded:Connect(color1)
end
workspace.MainFolder.ChildAdded:Connect(color2)
for i,v in pairs(workspace.MainFolder:GetChildren())do
v.ChildAdded:Connect(color1)
for i,v in pairs(v:GetChildren())do
color1(v)
end
end
script.Parent:WaitForChild("Main"):WaitForChild("Frame"):WaitForChild("Frame"):WaitForChild("ImageLabel").Image = game.Players:GetUserThumbnailAsync(game.Players.LocalPlayer.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
while true do
local A = GetPosition(game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position.X)
if A > 1 then
A = 1
elseif A < 0 then
A = 0
end
script.Parent:WaitForChild("Main"):WaitForChild("Frame"):WaitForChild("Frame").BackgroundColor3 = Color
script.Parent.Main.Frame.Frame.Size = UDim2.fromOffset((script.Parent.Main.Frame.AbsoluteSize.X-33)*A+22,22)
for i,v in pairs(game.Players:GetPlayers())do
if v.Character then
if v.UserId ~= game.Players.LocalPlayer.UserId then
local img = script.Parent.Main.Frame.Players:FindFirstChild(v.Name)
if not img then
img = script.Parent.Main.Frame.ImageLabel:Clone()
img.Name = v.Name
img.Position = UDim2.fromOffset(A*GetPosition(v.Character:WaitForChild("HumanoidRootPart").Position.X)+11,0)
img.Parent = script.Parent:WaitForChild("Main"):WaitForChild("Frame"):WaitForChild("Players")
img.Image = game.Players:GetUserThumbnailAsync(v.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
img.Visible = true
end
local A = GetPosition(v.Character:WaitForChild("HumanoidRootPart").Position.X)
if A > 1 then
A = 1
elseif A < 0 then
A = 0
end
img.Position = UDim2.fromOffset((script.Parent.Main.Frame.AbsoluteSize.X-33)*A+11,0)
end
end
end
wait()
end
Thanks for the help. Have a good day 