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

How do I script hold f to buy a tool?

Asked by 3 years ago
Edited 3 years ago

For the Past I've been trying to figure out and it would be helpful to note that, because my attempts have been unsuccesful which is unfortunate

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Can you be more specific? I think this will help?

local item = --your item path here
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

mouse.KeyDown:Connect(function(key)
    if key == "f" then
        wait(2) -- make it how long the holding will be
        local clone = item:Clone()
        clone.Parent = player:WaitForChild("Backpack")
        if player.Character.Humanoid.Health == 0 then
            wait(4.75)
            local clone = item:Clone()
            clone.Parent = player:WaitForChild("Backpack")
            --it's basically gives you the item if you died
        end
    end
end)

or you can just use proximity prompt, learn it on youtube!

local proximitypromt = --your proximity prompt path here

proximityprompt.Triggered:Connect(function()
    local item = --your item path here
    local player = game:GetService("Players").LocalPlayer
    local clone = item:Clone()
    clone.Parent = player:WaitForChild("Backpack")
    proximitypromot.ActionText = "Bought!"
end)

if none of the above works, then dm me on discord: Blue Duck#9891

(if you have discord)

0
DO NOT USE THIS METHOD. It uses mouse.KeyDown which is a deprecated method. Please use UserInputService instead of this method. Dovydas1118 1495 — 3y
0
Okay, sir! Thanks for the knowledge! May god bless you! WINDOWS10XPRO 438 — 3y
Ad

Answer this question