I just finished my upgradeable teleport tool. To upgrade you press R on the keyboard. Fsr it works even when the tool is unequipped, which wouldnt work for my game because Im planning on adding other tools that also use r to upgrade. How can I make sure that it only functions if the tool is equipped? script:
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
script.Parent.Activated:connect(function()
local Destination = Mouse.Hit
wait(5 - Level)
Body:MoveTo(Destination.p)
end)
Mouse.KeyDown:connect(function(k)
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)

1 comment
Thanks!