Basically, I want that button to fire a RemoteEvent which has 10 cmds. The localscript will be able to fire a cmd depending on the conditions.
Localscript:
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Full.Value = false
script.Parent.Parent.Image = “rbxasset://textures/ui/GuiImagePlaceholder.png”
if script.Parent.Parent.Item.Value == “” then
print(“nothing in slot 1”)
elseif script.Parent.Parent.Item.Value == “Hematogen 1” then
script.Parent.Parent.Parent.Hematogens.Value = script.Parent.Parent.Parent.Hematogens.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 30
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“1”)
elseif script.Parent.Parent.Item.Value == “Hematogen 2” then
script.Parent.Parent.Parent.Hematogens.Value = script.Parent.Parent.Parent.Hematogens.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 30
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“2”)
elseif script.Parent.Parent.Item.Value == “Medkit 1” then
script.Parent.Parent.Parent.Medkits.Value = script.Parent.Parent.Parent.Medkits.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 100
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“3”)
elseif script.Parent.Parent.Item.Value == “Medkit 2” then
script.Parent.Parent.Parent.Medkits.Value = script.Parent.Parent.Parent.Medkits.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 100
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“4”)
elseif script.Parent.Parent.Item.Value == “Medkit 3” then
script.Parent.Parent.Parent.Medkits.Value = script.Parent.Parent.Parent.Medkits.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 100
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“5”)
elseif script.Parent.Parent.Item.Value == “Bandage 1” then
script.Parent.Parent.Parent.Bandages.Value = script.Parent.Parent.Parent.Bandages.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 50
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“6”)
elseif script.Parent.Parent.Item.Value == “Bandage 2” then
script.Parent.Parent.Parent.Bandages.Value = script.Parent.Parent.Parent.Bandages.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 50
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“7”)
elseif script.Parent.Parent.Item.Value == “Bandage 3” then
script.Parent.Parent.Parent.Bandages.Value = script.Parent.Parent.Parent.Bandages.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 50
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“8”)
elseif script.Parent.Parent.Item.Value == “Bandage 4” then
script.Parent.Parent.Parent.Bandages.Value = script.Parent.Parent.Parent.Bandages.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 50
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“9”)
elseif script.Parent.Parent.Item.Value == “Bandage 5” then
script.Parent.Parent.Parent.Bandages.Value = script.Parent.Parent.Parent.Bandages.Value - 1
script.Parent.Parent.Parent.TotalPriceValue.Value = script.Parent.Parent.Parent.TotalPriceValue.Value - 50
script.Parent.Parent.Item.Value = “”
game.Workspace.PharmacyItemScript.PharmacyItem:FireServer(“10”)
end
end)
The localscript works, but for some reason the listener server script won’t.
script.PharmacyItem.OnServerEvent:Connect(function(cmd)
if cmd == “1” then
game.Workspace.PharmacySystem.Items.Hematogen1.Taken.Value = false
game.Workspace.PharmacySystem.Items.Hematogen1.Transparency = 0
elseif cmd == “2” then
game.Workspace.PharmacySystem.Items.Hematogen2.Taken.Value = false
game.Workspace.PharmacySystem.Items.Hematogen2.Transparency = 0
elseif cmd == “3” then
game.Workspace.PharmacySystem.Items.Med_Kit1.Taken.Value = false
game.Workspace.PharmacySystem.Items.Med_Kit1.Transparency = 0
elseif cmd == “4” then
game.Workspace.PharmacySystem.Items.Med_Kit2.Taken.Value = false
game.Workspace.PharmacySystem.Items.Med_Kit2.Transparency = 0
elseif cmd == “5” then
game.Workspace.PharmacySystem.Items.Med_Kit3.Taken.Value = false
game.Workspace.PharmacySystem.Items.Med_Kit3.Transparency = 0
elseif cmd == “6” then
game.Workspace.PharmacySystem.Items.Bandage1.Taken.Value = false
game.Workspace.PharmacySystem.Items.Bandage1.Transparency = 0
elseif cmd == “7” then
game.Workspace.PharmacySystem.Items.Bandage2.Taken.Value = false
game.Workspace.PharmacySystem.Items.Bandage2.Transparency = 0
elseif cmd == “8” then
game.Workspace.PharmacySystem.Items.Bandage3.Taken.Value = false
game.Workspace.PharmacySystem.Items.Bandage3.Transparency = 0
elseif cmd == “9” then
game.Workspace.PharmacySystem.Items.Bandage4.Taken.Value = false
game.Workspace.PharmacySystem.Items.Bandage4.Transparency = 0
elseif cmd == “10” then
game.Workspace.PharmacySystem.Items.Bandage5.Taken.Value = false
game.Workspace.PharmacySystem.Items.Bandage5.Transparency = 0
end
end)