so i have this script that gets a tool in to a players inventory when a player clicks 'h' what i want to do is make the player be able to use that only when he is close to an item and i want the tool to dissapear after a player has clicked 'h' here is what ive made
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key) Key = Key:lower() if Key == 'h' then local copy = game.Workspace.Tool:Clone()
copy.Parent = game.Players.LocalPlayer.Backpack end end)
You would need to use magnitude for that.
something like this (Im at school, so i cant test to see if it works or nah :P):
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:connect(function(Key) Key = Key:lower() if Key == 'h' then local mt = Mouse.Target local mh = Mouse.Hit.p if (mh-Player.Character.HumanoidRootPart.Position).magnitude <= 10 then if mt.ClassName == ("Tool") then mt:Clone() mt.Parent = game.Players.LocalPlayer.Backpack mt:Remove() end end end end)