I think there's some anomalies there. The button click is supposed to fire the "Save all tools" event. Which is supposed to be located in a local script inside the button, or inside the GUI. (I'm not sure if the location is a must, but i usually place it there.)
So, i suggest if you wanna follow my advice, scrap that script you have there, delete it. And follow my way.
Oh, before i continue, I just want to let you know that this method is not very efficient, therefore you might want to wait for someone to come up with a better solution. But if you're in a hurry, and don't mind writing some scripts and adding a few Remote events, you can follow this.
So, you create a local script in the BUY button, and in that local script you only have to write:
1 | player = game:GetService( "Players" ).LocalPlayer |
3 | script.Parent.MouseButton 1 Click:Connect(fucntion() |
4 | game.ReplicatedStorage.RemoteEvents.SaveAllTools:FireServer(player) |
Then, the server script will recieve the signal from the local script, and then.
1 | game.ReplicatedStorage.RemoteEvents.SaveAllTools.OnServerEvent:Connect( function (player) |
2 | if player.leaderstats.Bacon.Value > = 150 then |
3 | game.ReplicatedStorage.RemoteEvents.MAKEANEWREMOTEEVENT:FireClient( true ) |
5 | game.ReplicatedStorage.RemoteEvents.MAKEANEWREMOTEEVENT:FireClient( false ) |
Now i forgot to mention, you have to create another Remote event to handle the gui, be sure to replace "MAKEANEWREMOTEEVENT" with the remote event name, i'm sure you already know lol. And also make a local script to receive the signal, place it inside the where the "Buy" Gui is, name it whatever, but i personally love to name it "PopupHandler"
After you created a local script in the buy gui. You can do the scripting, it's something along the lines of:
1 | game.ReplicatedStorage.RemoteEvents.MAKEANEWREMOTEEVENT.OnClientEvent:Connect( function (state) |
3 | script.Parent.Parent.Parent.SaveAllToolsAndWeaponsCheck.Visible = true |
5 | script.Parent.Parent.Parent.NotEnoughBacon.Visible = true |
And that should work. I hope. If you have any trouble, add some debugging print here and there, and, just let me know. I'll try what i can do to help. Good luck.