Hey Devs,
I am looking for a way to find a tool that can either be in the player’s Backpack, or inside of their character (if it is equipped); during an event.
Basically, I am wanting to make a change to the tools color, based on the characters actions. The only problem, is that I cannot find a way to write the code so that it check the Backpack, and if the tool is not there, then it checks the Character.
This is the code I currently have, but it is not working; probably because I’m new to pcalls
:
local player = game.Players.LocalPlayer
local button = script.Parent
local prompt = script.Parent.Parent.Parent
local item = prompt.ItemName
button.MouseButton1Click:Connect(function()
local pclone = prompt:FindFirstChild("Phone")
local phone
pcall(function(succ,err)
phone = player.Backpack.Phone
if err then
phone = player.Character.Phone
print(err)
end
end)
if phone then
print("Gotta phone")
end
end)