Issue with click detector

So I’m adding a selling feature for my simulator game. I use a click detector to transfer my syrup(it’s about waffles) to money when I hit the sell button. After I click it, I have got an error that’s kind of hard to explain, but if I sell 128 syrup, I click next with the syrup I get 128 syrup instead of 1. I have some code in a local script in GUI:
local replicatedstorage = game:GetService(“ReplicatedStorage”)
local sellevent = replicatedstorage:WaitForChild(“Sell”)
local clickdetector = game.Workspace.SellBlock.ClickDetector
clickdetector.MouseClick:Connect(function(player)
player.leaderstats.Money.Value += player.leaderstats.Syrup.Value
player.leaderstats.Syrup.Value = 0
end)

I also have some more code in a script in StarterPack:
local replicatedstorage = game:GetService(“ReplicatedStorage”)
local remotedata = game:GetService(“ServerStorage”):WaitForChild(“RemoteData”)
local cooldown = 0.5
local sellevent = replicatedstorage:WaitForChild(“Sell”)
replicatedstorage.Remotes.Syrup.OnServerEvent:Connect(function(player)
if not remotedata:FindFirstChild(player.name) then return “NoFolder” end
local debounce = remotedata[player.Name].Debounce
if not debounce.Value then
debounce.Value = true

	player.leaderstats.Syrup.Value = player.leaderstats.Syrup.Value + 1 *(player.leaderstats.Sacrfices.Value + 1)
	
	
	wait(cooldown)
	debounce.Value = false
end

end)

Thanks for any help!

Could you send the hierarchy (Explorer) with this ClickDetector?

here you go I hope this good. Tell me if I should expend anything else.

Can you please format the code correctly?

You can do it by highlighting the code and pressing this button:

image

local replicatedstorage = game:GetService(“ReplicatedStorage”)
local sellevent = replicatedstorage:WaitForChild(“Sell”)
local clickdetector = game.Workspace.SellBlock.ClickDetector
clickdetector.MouseClick:Connect(function(player)
player.leaderstats.Money.Value += player.leaderstats.Syrup.Value
player.leaderstats.Syrup.Value = 0
end)

I also have some more code in a script in StarterPack:
local replicatedstorage = game:GetService(“ReplicatedStorage”)
local remotedata = game:GetService(“ServerStorage”):WaitForChild(“RemoteData”)
local cooldown = 0.5
local sellevent = replicatedstorage:WaitForChild(“Sell”)
replicatedstorage.Remotes.Syrup.OnServerEvent:Connect(function(player)
if not remotedata:FindFirstChild(player.name) then return “NoFolder” end
local debounce = remotedata[player.Name].Debounce
if not debounce.Value then
debounce.Value = true

```
	player.leaderstats.Syrup.Value = player.leaderstats.Syrup.Value + 1 *(player.leaderstats.Sacrfices.Value + 1)
	
	
	wait(cooldown)
	debounce.Value = false
end
```

StarterPack isn’t a good place for Script, you should put it in ServerScriptService