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!