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

How to detect that a player has a specific item selected in their backpack?

Asked by 4 years ago

I'm trying to make something that detects & upgrades any weapon that is actually selected, and while I can figure out how to get an unselected item from a players backpack and replace it; I can't figure out the concept behind actually detecting what a player currently has selected in their backpack real-time.

player.Backpack:FindFirstChild"gun1":Destroy()
game.ServerStorage.gun2:Clone().Parent = player.Backpack

1 answer

Log in to vote
1
Answered by
Pupppy44 671 Moderation Voter
4 years ago

The tool the player has equipped is a child of the player's character.

game:GetService("Players").LocalPlayer.Character:FindFirstChildWhichIsA("Tool")
0
Ah, thank you. I didn't know that it automatically makes selected tools a child. dank_mayonaise7 4 — 4y
Ad

Answer this question