Hey there!
So, i’ve been facing problems with a thing im doing.
Alright, so let me make an example;
I use the hatching system, i pick triple hatch because i have enough for it, it works perfectly and takes the perfect amount. Now i try to hatch again, works perfectly fine and takes the perfect amount again, but then i hatch the third time, and it works perfectly fine but with a twist, it takes double the amount now. So if it costed 18k, now it would take 36k.
Now, i don’t know when it takes double and also the example actually happened, the only reason i know this happens is cause this happened two times.
I don’t know why this is happening but, maybe it’s the fact i use a remote function.
Heres the code;
Server:
EggCheck3.OnServerInvoke = function()
local e2 = egg.Cost.Value*2
if Player.Coins.Value >= e2 then
return true
else
Rep.DisplayMessage:FireClient(Player, tostring("You need "..e2 - Player.Coins.Value.." Coins to open this egg!"), "Message")
end
end
Rep.DisplayHatchOptions:FireClient(Player, egg.EggName.Value, egg.Cost.Value, RandomPet,"Golden","Coins")
wait(3)
Rep.HatchCost.OnServerEvent:Connect(function(player,ID,op)
print(ID)
if ID == "Egg1" then
print(op)
if op == 1 then
Player.Coins.Value -= egg.Cost.Value
elseif op == 3 then
local e = egg.Cost.Value*2
print(e)
Player.Coins.Value -= e
end
end
end)
Client:
DisplayHatchOptions.OnClientEvent:Connect(function(EggName,Cost,Pet,Type,Currency,ID)
local TripleMsgClone = TripleHatchMsg:Clone()
local desc = TripleMsgClone.Frame.Desc
local buy3 = TripleMsgClone.Frame.Option2
local buy1 = TripleMsgClone.Frame.Option1
local cancel = TripleMsgClone.Frame.Cancel
desc.Text = ("Buy and open a ".. EggName .. " for " .. Cost .. " " ..Currency)
TripleMsgClone.Parent = PlayerGui
buy1.MouseButton1Click:Connect(function()
Rep.HatchCost:FireServer(EggName,1)
Debris:AddItem(TripleMsgClone,0.1)
hatch(Pet,Type)
end)
buy3.MouseButton1Click:Connect(function()
local yesnt = Rep.EggCheck3:InvokeServer()
if yesnt == true then
Rep.HatchCost:FireServer(EggName,3)
Debris:AddItem(TripleMsgClone,0.1)
hatch(Pet,Type)
wait()
hatch(Pet,Type)
wait()
hatch(Pet,Type)
end
end)
cancel.MouseButton1Click:Connect(function()
Debris:AddItem(TripleMsgClone,0.1)
end)
end)
Edit: I found out the possible reason, i haven’t really tested if it happens randomly or when i click fast. When i click triple hatch (or even single hatch) triple hatch is only supposed to cost double the amount of single hatch, (single hatch is 9k) but instead of costing 18k, it costs a lot more. The reason why (i tested a bit) is that if i click “triple hatch” more than once, it costs a lot more than 18k.
I could easily fix it by using a Debounce, but anything i did hasn’t worked, any ideas on how i could make a debounce work?
Thanks