Hello, i want to make a length bar for my race game, something like Tower of Hell. It’s working while only one player is playing. But when 2 player plays at the same time, 2nd player to join the game can’t see first player’s avatars image on the length bar. And first player can see second one’s image but the image doesn’t move. Here’s the scripts
Script
local players = game.Players
game:GetService("Players").PlayerAdded:Connect(function(player)
if player:FindFirstChild("PlayerGui") then
while wait(0.5) do
for _, plr in pairs(game.Players:GetChildren()) do
local localimage = plr:WaitForChild("PlayerGui"):WaitForChild("Length"):WaitForChild("Frame"):WaitForChild(plr.Name.."Image")
local localchar = game:GetService("Workspace")[plr.Character.Name]
local plrhrp = localchar:FindFirstChild("HumanoidRootPart")
local plrlength = math.ceil(plrhrp.Position.Z)
local plrasdsad = plrlength - 20
localimage.Position = UDim2.new(-0.035 + plrasdsad/16000, 0, 0.5, 0)
localimage.ImageTransparency = 0
print(plrlength)
print(plrasdsad)
print(plr.Name)
end
end
end
end)
Script
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size48x48
local players = game.Players
players.PlayerAdded:Connect(function(plr)
wait(2)
for _, plrr in pairs(game.Players:GetChildren()) do
local cloneimage = plr.PlayerGui.Length.Frame.ImageLabel:Clone()
cloneimage.Image = players:GetUserThumbnailAsync(plr.userId, thumbType, thumbSize)
cloneimage.Parent = plrr.PlayerGui:WaitForChild("Length"):WaitForChild("Frame")
cloneimage.Name = plr.Name.."Image"
cloneimage.ImageTransparency = 0
end
end)
Local Script
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size48x48
local players = game.Players
local player = players.LocalPlayer
while wait(2) do
player.PlayerGui.Length.Frame:WaitForChild(player.Name.."Image").Image = players:GetUserThumbnailAsync(player.userId, thumbType, thumbSize)
player.PlayerGui.Length.Frame:WaitForChild(player.Name.."Image").ImageTransparency = 0
end
If these informations are not enough, you can ask anything you are wondering