This works fine aside from the fact that if "Lunch" tool isn't in the Backpack it does nothing. This is in a GUI, also this is a local script
How can I get this if statement to check if "Lunch" is in the Players Backpack??
this only works if I do have the tool
game.Players.LocalPlayer.Backpack.Lunch:Remove() --- To remove it rep.Value = rep.Value - 2 s.Dialog.Choice4.Text = "-2 Rep!" s.Dialog.Choice1.Visible = false s.Dialog.Choice2.Visible = false s.Dialog.Choice3.Visible = false s.Dialog.Choice4.Visible = true choosen = thankslunch Write() wait() s:Destroy()
If I don't have the tool this code won't start,
s.Dialog.Choice4.Text = "Don't Have Lunch" s:Destroy()
The whole function is here;
s.Dialog.Choice4.MouseButton1Click:connect(function() if game.Players.LocalPlayer.Backpack.Lunch then game.Players.LocalPlayer.Backpack.Lunch:Remove() rep.Value = rep.Value - 2 s.Dialog.Choice4.Text = "-2 Rep!" s.Dialog.Choice1.Visible = false s.Dialog.Choice2.Visible = false s.Dialog.Choice3.Visible = false s.Dialog.Choice4.Visible = true choosen = thankslunch Write() wait() s:Destroy() elseif game.Players.LocalPlayer.Backpack.Lunch ~= nil then s.Dialog.Choice4.Text = "Don't Have Lunch" s:Destroy() end end)
Thanks for reading! Please help! I am confused