Can someone help me in this problem of making progress bar?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a Player progress bar. where if the player steps on a checkpoint then the Player progress bar will run according to the checkpoint, but i have problem in making my Player progress bar. can someone help me?

this is an example of a game

and this is my progress bar

This Code LocalScript

local TS = game:GetService("TweenService")
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local verticalbar = script.Parent:WaitForChild("Vertical") 
local pointfolder = game.Workspace:WaitForChild("StartGuiRPlayer")
local startpoint = pointfolder:WaitForChild("Mulai")
local endpoint = pointfolder:WaitForChild("End")

local characters = {}
local StartToEnd = endpoint.Position - startpoint.Position

local function get_player_ui(player)
	local sample = script:WaitForChild("FotoPlayer"):Clone()
	sample.Name = player.Name
	sample.TextLabel.Text = player.Name
	sample.Position = UDim2.fromScale(0,0.5)
	sample.Parent = verticalbar

	local s,e = pcall(function()
		sample.Image = Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	end)
	if not s then
		sample.Image = "rbxassetid://"..15847365339
	end


	return sample
end

local function trackplayer(player)
	local character = player.Character or player.CharacterAdded:Wait()


	if not character then
		characters[player.Name] = nil
	end

	characters[player.Name] = {
		Char = character,
		UIObject = verticalbar:FindFirstChild(player.Name) or get_player_ui(player)
	}
end

Players.PlayerAdded:Connect(function(player)
	trackplayer(player)
end)
Players.PlayerRemoving:Connect(function(player)
	if not characters[player.Name] then
		return
	end

	if characters[player.Name].UIObject then
		characters[player.Name].UIObject:Destroy()
	end
	characters[player.Name] = nil
end)

for i, v in pairs(game.Players:GetChildren()) do
	trackplayer(v)

end

while true do
	for i, v in pairs(characters) do
		if not v or not v.UIObject then
			continue
		end

		local StartToPlayer = workspace.checkpoint:FindFirstChild(player.leaderstats.Stage.Value).Position - startpoint.Position
		local length = StartToEnd:Dot(StartToEnd)
		local progression = math.clamp(StartToPlayer:Dot(StartToEnd) / length,0,1) 

		v.UIObject.Position = UDim2.fromScale(progression,0.5)
	end
	task.wait()
end

if you don’t understand you can make my Roblox studio >>>
Bar Obby.rbxl (65.2 KB)

Use a remote event so that you are able to connect your local script to the server and thus allow all players to see the changes. Local script affects only the client side.

1 Like

Use Server Script instead of LocalScript, in LocalScript you just trigger the remote event and script it on the server side so everyone sees the changes

1 Like

can you give me an example of a script i am very confused about this i am not very good at scripting

all scripts changed to Server is it successful???

Okay. After further inspection I noticed you were using the stage values as a way to measure progress (ones stored at leaderstats). So you could actually use only a local script.
Here is just a rough edit just to get the point across.

local TS = game:GetService("TweenService")
local Players = game:GetService("Players")
local Local_player = game.Players.LocalPlayer
local verticalbar = script.Parent:WaitForChild("Vertical") 
local pointfolder = game.Workspace:WaitForChild("StartGuiRPlayer")
local startpoint = pointfolder:WaitForChild("Mulai")
local endpoint = pointfolder:WaitForChild("End")

local characters = {}
local StartToEnd = endpoint.Position - startpoint.Position

local ProgressTrackerRE = game:GetService("ReplicatedStorage"):WaitForChild("ProgressTracker")


local function update_get_player_ui(player, progression, n)
	if verticalbar:FindFirstChild(player.Name) then
		verticalbar:FindFirstChild(player.Name):Destroy()
	end
	local sample = script:WaitForChild("FotoPlayer"):Clone()
	sample.Name = player.Name
	sample.TextLabel.Text = player.Name
	sample.Position = UDim2.fromScale(progression,n)
	sample.Parent = verticalbar

	local s,e = pcall(function()
		sample.Image = Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
	end)
	if not s then
		sample.Image = "rbxassetid://"..15847365339
	end



end



Players.PlayerAdded:Connect(function(player)
	update_get_player_ui(player, 0, 0.5)
end)
Players.PlayerRemoving:Connect(function(player)
	verticalbar:FindFirstChild(player.Name):Destroy()
end)

for i, player in pairs(game.Players:GetChildren()) do
	update_get_player_ui(player, 0, 0.5)
end

for i, player in pairs(game:GetService("Players"):GetChildren()) do
	local playerLeaderstat = player:WaitForChild("leaderstats")
	local playerStageNumber = playerLeaderstat:WaitForChild("Stage")
	playerStageNumber.Changed:Connect(function()
		local StartToPlayer = workspace.checkpoint:FindFirstChild(playerStageNumber.Value).Position - startpoint.Position
		local length = StartToEnd:Dot(StartToEnd)
		local progression = math.clamp(StartToPlayer:Dot(StartToEnd) / length,0,1) 
		update_get_player_ui(player, progression, 0.5)
	end)
end
1 Like

Thank you very much it works very well thank you :gift_heart: :sparkling_heart: :gift_heart: :grinning:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.