hey everyone, I am new to LUA and scripting in general. I want to make a script that when you press T the game tells you how far you have traveled from when you hit T.
I have that all working, but the result seems to be an exponential amount and not linear. I am using .scaleSquared to get the difference between two "vector three" values. and If I use just .scale it doesn't work anymore. should I be using some other method for calculating the difference between the two vector points?
Here is the script:
local player = Game.GetLocalPlayer() local isposition1 = 0 local p1 = player:GetWorldPosition() local p2 = player:GetWorldPosition() local MapScale = 25000 local function ExecuteOnBind(player, keyPress) if player == player then if keyPress == "ability_extra_24" then --set position1 on first keypress then alternate to second postion if isposition1 == 0 then p1 = player:GetWorldPosition() isposition1 =1 for i = 1, 60 do p2 = player:GetWorldPosition() local distanceTraveled = (p1-p2).sizeSquared local StringVector = tostring(math.floor(distanceTraveled/MapScale)) UI.PrintToScreen(StringVector) Task.Wait(0.2) end end isposition1 = 0 --calculate the distance traveled and display the change local distanceTraveled = (p1-p2).size local StringVector = tostring(math.floor(distanceTraveled/MapScale)) UI.PrintToScreen(StringVector) end end end player.bindingPressedEvent:Connect(ExecuteOnBind)