My tool has a function where they can press the R key at any time to upgrade their tool for a cost. The vast majority of my friends do not have computers, which led me to thinking about how I could add a button that upgrades the tool when they can't really press R. I want to add something along the lines of a button that only appears when holding the tool, but does the same thing as the R key would on the computer. Any ideas? My current script is below:
repeat wait() until game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer
local Body = Player.Character
local Mouse = Player:GetMouse()
local Level = script.Parent.Level.Value
local Cash = Player.leaderstats.Cash
local Tool = script.Parent
local Equipped
script.Parent.Activated:connect(function()
if not Equipped then return end
local Destination = Mouse.Hit
wait(5 - Level)
Body:MoveTo(Destination.p)
end)
Mouse.KeyDown:connect(function(k)
if not Equipped then return end
k = k:lower()
if k == "r" then
if Level < 5 then
if Cash.Value >= (Level * 5) then
Cash.Value = Cash.Value - (Level * 5)
Level = Level + 1
end
end
end
end)
Tool.Equipped:connect(function()
Equipped = true
end)
Tool.Unequipped:connect(function()
Equipped = false
end)
