The script is for a inventory system whenever I click the water bottle on the ground its suppose to find the player go to the GUI in the players playergui and see if Item1 through item5 are available and the first one it finds the text and the string value should be the item name
scripts here
script.Parent.ClickDetector.MouseClick:connect(function(plr) script.Parent.StringValue.Value = plr.Name if plr.PlayerGui.Inventory.Frame.Item1.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item1.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item1.Taken.Value == "Taken" then if plr.PlayerGui.Inventory.Frame.Item2.Taken.Value == "Nontaken" then plr.PlayerGui.Inventory.Frame.Item2.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item2.Taken.Value == "Taken" then if plr.PlayerGui.Inventory.Frame.Item3.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item3.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item3.Taken.Value == "Taken" then if plr.PlayerGui.Inventory.Frame.Item4.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item4.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item4.Taken.Value == "Taken" then if plr.PlayerGui.Inventory.Frame.Item5.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item5.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item5.Taken.Value == "Taken" then script.Parent:remove() end end end end end end)
The first error was within 5 through 7. You could have added and
, and it would work better. What you're telling ROBLOX is to basically cancel all the other elseif's.
script.Parent.ClickDetector.MouseClick:connect(function(plr) if plr.PlayerGui.Inventory.Frame.Item1.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item1.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item1.Taken.Value == "Taken" and plr.PlayerGui.Inventory.Frame.Item2.Taken.Value == "Nontaken" then plr.PlayerGui.Inventory.Frame.Item2.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item2.Taken.Value == "Taken" and plr.PlayerGui.Inventory.Frame.Item3.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item3.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item3.Taken.Value == "Taken" and plr.PlayerGui.Inventory.Frame.Item4.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item4.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item4.Taken.Value == "Taken" and plr.PlayerGui.Inventory.Frame.Item5.Taken.Value == "NonTaken" then plr.PlayerGui.Inventory.Frame.Item5.ItemName.Value = "Bottle Water" elseif plr.PlayerGui.Inventory.Frame.Item5.Taken.Value == "Taken" then script.Parent:Destroy() end end)