What's wrong with my script?

for i,v in pairs(game.Players:GetChildren()) do
	v.Parent.CharacterAdded:Connect(function(char)
					for _, currentGUI in pairs (v.PlayerGui:GetChildren()) do
						if currentGUI.Name == "HeightGui" then
							currentGUI:Destroy() print("Destroyed")
						end
					end
					
					for _, GUI in pairs (game.StarterGui:GetChildren()) do
						if GUI.Name == "HeightGui" then
							GUI:Clone().Parent = v.PlayerGui print("Replaced")
			  end
		end
	end)
end

there are no errors in the output but it doesn’t work

You are calling v.Parent.CharacterAdded, by v.Parent is going to equal game.Players, not the Player(v), itself. CharacterAdded is not a event of the Players service.

Try this:

v.CharacterAdded:Connect(function(char)

Even though this is not the issue, why are you using :GetChildren()? Just use :GetPlayers().

What difference does it make? The Developer Hub mentions that the two methods work practically the same, and it doesn’t affect readability. It’s all about personal preference.

I’m very sorry i found the solution myself

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		for i,v in pairs(plr.Parent:GetChildren()) do
	for _, currentGUI in pairs (v.PlayerGui:GetChildren()) do
			if currentGUI.Name == "HeightGui" then
				currentGUI:Destroy() print("Destroyed")
			end
		end
		
		for _, GUI in pairs (game.StarterGui:GetChildren()) do
			if GUI.Name == "HeightGui" then
				GUI:Clone().Parent = v.PlayerGui print("Replaced")
				end
				
			end
		end
		
			
		end)
	end)
	

I thought it affected readability in some way that I wasn’t very sure of - my bad.

You aren’t technically wrong. Readability is all about how easily comprehensible it is to you. So if you find it easier to understand by using :GetPlayers(), do that. I just personally don’t read the options differently.