I've made a code that checks if a tool is in the Backpack or not. If it is in the backpack, the code is supposed to bypass the primary action and move on. Unfortunately, it runs the primary action regardless if the tool is in the Backpack or in the Player. I used a print code to test this, and sure enough, each time it runs, if the tool was in the Backpack it printed "Backpack" and if it was in the player it printed my name. Any ideas why? This is in a local script inside of a tool. Thanks in advance!
if player.Backpack.MyValue.Value == false then FanimTrack:Play() wait(.4) player.Character.Head.MySound:Play() wait(.6) if bin.Parent ~= "Backpack" then enabled = false print(bin.Parent.Name) player.Backpack.MyValue.Value = true --My FireServer Event wait(4) player.Backpack.MyValue.Value = false wait(4) enabled = true end FanimTrack:Stop() end
You are trying to compare an object to a string. You wanted to compare it's Name to your string.
bin.Parent.Name ~= "Backpack"