Roblox player position bar not working

I’m trying to make a player position bar, much like Tower of Hells, but the code I made doesn’t work. In fact, it doesn’t seem to do anything to the cloned abject at all

code:

local bar = script.Parent.Bar
local plrFrame = script.Parent.Plr
local playerservice = game:GetService("Players")
local endpoint = game.Workspace.EndCFrame

task.wait(1)

local function update()
	local plrs = playerservice:GetChildren()
	for _, v in ipairs(plrs) do
		local plrposition = v.Character.HumanoidRootPart.Position
		local clone = plrFrame:Clone()
		clone.Visible = true
		clone.Parent = script.Parent.clones
		local mag = (plrposition - endpoint.Position).Magnitude
		print(mag)
		clone.Position = UDim2.fromScale(math.ceil(mag)/1000, 0.9)
		clone:Destroy()
	end
end

while task.wait(0.1) do
	
	update()
end

Try adding one line here:

        clone.Position = UDim2.fromScale(math.ceil(mag)/1000, 0.9)
        task.wait(0.1)
		clone:Destroy()

You are doing clone:Destroy() right after creating a clone. Maybe remove that line of code?

I added it and it still doesn’t do anything

get rid of the clone:Destroy()

Still doesn’t work unfortunatley

local bar = script.Parent.Bar
local plrFrame = script.Parent.Plr
local playerservice = game:GetService("Players")
local endpoint = game.Workspace.EndCFrame

task.wait(1)

local cachedFrames = {}
local function update()
	local plrs = playerservice:GetChildren()
	for _, v in ipairs(plrs) do
        if cachedFrames[v.UserId] then cachedFrames[v.UserId]:Destroy() end
		local plrposition = v.Character.HumanoidRootPart.Position
		local clone = plrFrame:Clone()
		clone.Visible = true
		clone.Parent = script.Parent.clones
		local mag = (plrposition - endpoint.Position).Magnitude
		print(mag)
		clone.Position = UDim2.fromScale(math.ceil(mag)/1000, 0.9)
        cachedFrames[v.UserId] = clone
	end
end

while task.wait(0.1) do
	
	update()
end

Then maybe something like this?

Oh wait, so your code doesn’t work to begin with?
We can’t just fix it without knowing the context of what a PlayerFrame is, and what your project’s hierarchy looks like.

EDIT:
You will need to provide more details explaining better what your project looks like, what you have already done and exactly what is the result you want.
Alternatively you can also share the roblox place if it’s not private, so that I can edit it on the spot.

how about changing

clone.Parent = script.Parent.clones

to

clone.Parent = script.Parent

There’s no errors so i’m suspecting it might have something to do with the calculations I’m doing. What would need to see in order to fix this?

gui.rbxm (7.1 KB)
Here’s a file with the gui, let me know if there’s any problems

Well, can you explain if you see anything? How does the bar look like? Is it vertical, is it horizontal??
What is a plrFrame in this context?
Where is this script Parented to?

The frame doesn’t appear at all, the script is parented to a screen gui

EDIT: can you pls explain to me what a plrframe is?

EndCFrame is not a valid member of Workspace “Workspace”

after putting into startergui

You mention it here, I don’t know what it is. That’s why I’m asking :smiley:

from the gui.rbxm he sent its a frame

just make a part and name it EndCFrame and put in somewhere in workspace. I’m trying to adjust the frame based on how far the player is from that part

Ohhhhhhh, that’s the frame that I’m trying to change the position of

heres my result lol

Okay give me a second, trying to open your file.