#Code im using doesn't work at all, is it something to do with the equipping tool thing?
2 messages · Page 1 of 1 (latest)
local player = game.Players.LocalPlayer
local character = player.Character
local head = character:WaitForChild("Head")
local starterGui = game.StarterGui
local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Parent = starterGui
local textLabel = Instance.new("TextLabel")
textLabel.Text = "Looking 0 units away"
textLabel.Size = Vector2.new(200, 50)
textLabel.Position = UDim2.new(1, -200, 0, 0)
textLabel.AnchorPoint = Vector2.new(1, 0)
textLabel.Font = Enum.Font.SourceSans
textLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
textLabel.BackgroundTransparency = 1
textLabel.Visible = false
textLabel.Parent = frame
player.Equipped:Connect(function(tool)
if tool.Name == "MyTool" then
textLabel.Visible = true
else
textLabel.Visible = false
end
end)
while true do
wait(0.5)
if textLabel.Visible then
local currentPosition = head.Position
local currentDirection = head.CFrame.LookVector
local distance = currentDirection.magnitude
textLabel.Text = "Looking " .. distance .. " units away"
print("Distance calculated: " .. distance .. " units")
end
end