Hey everybody. I had made a post about this a while back but the solution didn’t work exactly. When 3 or more people joined the game the obby progress bar stopped working sadly.
Problem
So I attempted to make a progress bar for my obby game and had a few errors along the way.
It worked how it was intended to work when there was only one person. However when there were more it stopped working. Here is the code for the bar.
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
local img = script.Parent.Main.Frame.Players:FindFirstChild(v.Name)
if v.Character then
if v.UserId ~= game.Players.LocalPlayer.UserId then
if not img then
img = script.Parent.Main.Frame.ImageLabel
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
The issue is it cannot find the Image label for the player.
Additional Information
Here is the explorer tab for it.
And
The error that showed up on console.
If you can help thank you so much!