UIS.InputChanged:Connect(function(input)
if player:DistanceFromCharacter(Vector3) > 10 then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.FtoPickup.Text = ":"..item.Minutes.Value.." Minutes to get "..item.Parent.Name
not really sure someone told me to use player:DistanceFromCharacter(Vector3) Because i was trying get the object by going near it instead of putting your mouse on it but im not sure how to do that
Is Vector3 a dictionary? Show what’s in the Vector3 variable. If you want to check if the player is close to something, you need to give it a position of what you want to compare to
The vector3 is a point where you want to get the distance from, Vector 3 > 10 wont work because 1, There is no y axis value and there is only a x axis value.
Change you’re code to this:
UIS.InputChanged:Connect(function(input)
if player:DistanceFromCharacter(Vector3.new(--You're point.) > Vector3.new(-- PartPosition) then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.FtoPickup.Text = ":"..item.Minutes.Value.." Minutes to get "..item.Parent.Name
end
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
UIS.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.E and not gpe then -- if the player presses E and they're not typing or anything then
local selectedItem = Mouse.Target and Mouse.Target or nil
if selectedItem ~= nil and selectedItem then
print(Player:DistanceFromCharacter(selectedItem.Position))
if Player:DistanceFromCharacter(selectedItem.Position) <= 10 then --LESS THAN 10, NOT greater.
end
end
end
end)
When you press E with your mouse over an item, this will now print the distance between the item and the character. Hopefully you can learn from this and apply this to your own script, I’d help you more if you could provide more context to the situation
That should be a local script by the way, it will print the distance from the part and the character, so you can now use the distance to determine whether or not the part should be picked up.