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

How would I "pickup" an item with a key? [ANSWERED]

Asked by 8 years ago

my code:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local function pickup(key)
    if key == "f" then
        game.Players[player.Name]:WaitForChild("Hunger").Value = game.Players[player.Name]:WaitForChild("Hunger").Value -5
        script.Parent:Remove()
    end
end

mouse.KeyDown:connect(pickup)

I only want this to be able to activate when the player is standing near and is looking at the item, how would I do that? thanks

Answer this question