Store System Gives More Tools Every Time I Buy

You can write your topic however you want, but you need to answer these questions:

  1. Q: What do you want to achieve? Keep it simple and clear!
    A: I have a shop system with a ScreenGui and when you click to the item you want to buy, it checks if you have enough cash and then gives you the tool.

  2. Q: What is the issue? Include screenshots / videos if possible!
    A: It gives the tool but it gives tools at more amount every time you buy (Like i showed below). But I don’t want that.

    First Time . … … … … 1 Tool
    Second Time … … … 2 Tools
    Third Time … … … … 3 Tools
    n Time … … … … … … n Tools

  3. Q: What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    A: I don’t know if there is any solutions because I don’t even know how can I describe my problem in one sentence. Also I couldn’t try any solutions myself because there is no any errors, I don’t know why it gives more and more…

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

All my scripts are below:

  1. GUIReplicator
  • Stored in StarterGui
  • Has 3 childs:
    • TemplateShopGUI (The Main Gui’s Template: There are no items)
    • TemplateCell (Used to add items to the Gui and includes a ViewportFrame to display item)
    • Items (The folder used to store items and it’s data like: CFrame, Size, SpinSpeed, SpinAxis and Price)
  • GitHub / GUIReplicator
  1. PurchaseScript
  1. TriggerScript
  • Used to fire GenerateGUI() function in GUIReplicator
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    
    local Part = script.Parent
    local ProximityPrompt = Part.ProximityPrompt
    local InteractShop = ReplicatedStorage:WaitForChild("InteractShop")
    
    ProximityPrompt.Triggered:Connect(function(Player)
    	InteractShop:FireClient(Player)
    end)
    

I have no more scripts included guys. I hope you guys can find out where is the problem. Because I couldn’t. Good luck.

Best Regards,
taavZSub

The problem comes from this part in the GuiReplicator script:

PurchaseAmount.OnClientEvent:Connect(function(Succeed)
						if Succeed then
							GiveTool:FireServer(CloneItem.Name)
							CellTweens.ToSucceed:Play()
						else warn("Insufficient cash! POOR!") CellTweens.ToFail:Play() end
					end)

You are connecting the event too much times, making it give extra tools every time the button is clicked. Change Connect to Once and that will be fixed
I also recommend giving the tool on the server, exploiters can just fire the give tool event and get free tools

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.