Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

can i have an example for magnitude?

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

✓ Accepted answer

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 comment

1

use player:DistanceFromCharacter(vector3 value)

This discussion is preserved as it was. New answers, comments, and votes are closed.