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

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

Asked by
JollyDumb -21
7 years ago

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

0
Use magnitude and mouse.target. Nikkulaos 229 — 7y

1 answer

Log in to vote
0
Answered by
Nikkulaos 229 Moderation Voter
7 years ago

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.

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 JollyDumb -21 — 7y
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 loulou1112 35 — 7y
0
^ Lol yes, thank you Nikkulaos 229 — 7y
Ad

Answer this question