Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can i have an example for magnitude?

Asked by
danglt 185
5 years ago

Trying to make it were if i press "E" it will do something but i want it so you have to be close to the part for it to function.

game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then

        print("E was pressed")

    end 
end)

1 answer

Log in to vote
0
Answered by
Diltz_3 75
5 years ago
Edited 5 years ago

Ok...

local Part = workspace.Part_Example

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(Key)
    if Key.KeyCode == Enum.KeyCode.E then
        local Get_mag = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - Part.Position).magnitude
        print("Magnitude is:",Get_mag)
    end
end)

If I helped accept answer or I don't know..

1
use player:DistanceFromCharacter(vector3 value) User#23365 30 — 5y
Ad

Answer this question