So I have a Murder-Mystery-Style Inventory system, and whenever I press an imageButton, let's say the Default Knife, It correctly gives me the item, but if I press it again and again, it'll keep giving me the item! I have tried to make 2 scripts to prevent this, but neither of them are working.. so can someone PLEASE review them and tell me what I'm doing wrong?
Script 1:
script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.Backpack.DefKnife == true then
return
end
end)
Script 2:
script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.Backpack.DefKnife = game.Players.LocalPlayer.Backpack.DefKnife then
return
end
end)
And In case someone is wondering, here is the script to give the item:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Tools.DefKnife:Clone().Parent = game.Players.LocalPlayer.Backpack
end)

1 comment
Yes! Thank you sooo much! I have been looking for a script to do this for so long! :D