I know there are topics on this, I looked through them and am using the scripts from it.
Goal: When I activate the tool (click on the screen w/ the tool equipped) it is removed from my backpack
Note: The tool is a clone from lighting
Script:
function waterDrunk()
local player = game.Players
if player.Backpack:FindFirstChild("Water") and player.Backpack["Water"]:IsA("Tool") then
game.Players.Backpack.Water:Destroy()
end
if player.Character and player.Character:FindFirstChild("Water") and player.Character["Water"]:IsA("Tool") then
game.Players.Character["Water"]:Destroy()
end
print("water gone")
end
game.Lighting.Water.Activated:Connect(waterDrunk)
There is not a Backpack inside the game.Players every Player has a Backpack you need to select them. You would need to add something as a variable for the player for this to work
You define âplayerâ with players, meaning the script isnât checking a player themself. It only checks the WHOLE tab as in âIs âBackpackâ inside âPlayersââ rather than âIs âBackpackâ inside 'a Playerâ.
To solve this you need to define âplayerâ with a singular player by either using a local script (game.Players.LocalPlayer) or you could use this: