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

How do I script hold f to buy a tool?

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

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)

2 comments

0

DO NOT USE THIS METHOD. It uses mouse.KeyDown which is a deprecated method. Please use UserInputService instead of this method.

0

Okay, sir! Thanks for the knowledge! May god bless you!

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