i would make distance meter gui like this but my distance meter is broken :
screenshoot of mine:
I need help to fix this script:
Client Script :
local player = game.Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui")
local ui = gui:WaitForChild("FruitNotifier")
game.Workspace.DistanceValue.Changed:Connect(function(value)
ui.FarAwayText.Text = value
end)
DistanceScript :
local distance = game.Workspace.DistanceValue
local player = game.Players.LocalPlayer
local part1 = player.Character.HumanoidRootPart
local part2 = game.Workspace.DevilFruitSpawner.SpawnedDFS:GetChildren().Handle
while wait(10) do
local magnitude = (part1.Position - part2.Position).magnitude
distance.Value = ""..math.floor(magnitude)..""
end
General idea
Every time the player moves, we calculate the distance from the player and the DevilFruitSpawner then change the gui text.
This is pseudo code
if humanoid.MoveDirection.Magnitude > 0 then -- Player must be moving, thus their position is changing
local distance = (Position of player - Position of Devil fruit spanwer).Magnitude -- Get distance
GUI.TextBox.Text = distance -- Update distance whenever player is moving
end
local distance = game.Workspace.DistanceValue
local player = game.Players.LocalPlayer
local humanoid = player.Character:WaitForChild("Humanoid")
local part1 = player.Character.HumanoidRootPart
local part2 = game.Workspace.DevilFruitSpawner.SpawnedDFS:GetChildren().Handle
if humanoid.MoveDirection.Magnitude > 0 then
local distance = (part1.Position - part2.Position).Magnitude
GUI.TextBox.Text = distance
end