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)
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..