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

how can u make a player get close to an item and press f the get the item?

this is not working

local Player = game.Players.LocalPlayler local mouse = Player:GetMouse() local tool = game.workspace.Tool

mouse.KeyDown:connect(function(Key) tool:Clone().Parent = player.Backpack end

1 comment

0

Use magnitude and mouse.target.

1 answer

When using the keybind, make sure to use mouse.target and check if your (torso.Position-object.Position).magnitude is greater than or equal to any number.

Something like this (I am at school right now, so i cant really check if i wrote this right lol): local m = player:GetMouse() local mt = m.Target

if (m.Hit.p - player.Character.Torso.Position) <= 10 then local item = mt --etc, etc...

If this didnt help then please say so.

3 comments

0

umm id realy get it i dont want to teleport or something i want like when a player gets close to an item and he presses lets say h he would get an item n his backpack

0

none of that teleports anything. just add the if (m.Hit.p - player.Character.Torso.Position) <= 10 then local- bla bla bla in the keydown function. also actually dont use mouse.keydown, use userinputservice

0

^ Lol yes, thank you

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