At least try my friend, before trying to say something. this is the solution, if you don’t believe it, try to find the solution yourself.
Removing an arbitrary keyword from the original code isn’t going to solve it. The original code is flawed in a way that the code which resets the debounce is misplaced.
He didn’t say this wouldn’t work, he said that using local or not on the debounce would make no difference in your situation. Many solutions here might be correct, everyone got their own way of making something work. It all depends if it’s suitable enough for the person using the code.
The post was created to solve the debounce issue, not the script, so there’s no reason anyone here could solve the entire post creator script. if he looks at the script clearly, he will see the bugs. removing “local” from debounce will only solve one of its script issues.
Why are y’all having a full on blood moon death festival over a debounce? Why can’t you just use os.clock
as @ATrashScripter said?
This is not true. In the case that it is, no one will really notice. os.clock uses CPU time, unlike tick
. Also, os.clock kinda intended for things like this.
Anyways, please prove me wrong. Getting proved wrong makes you a better scripter
this is the most non-performance friendly and most “useless” solution, if you take away the “local” from debounce the script will work as expected.
All the solutions he could use:
yielding code:
--code
local debounce = false
local cooldown = 0.5 --set to whatever u want
script.Parent.MouseButton1Click:Connect(function()
if debounce then
debounce = false
local hasShinyBoost = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21797590) -- check pass
if hasShinyBoost then
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
else
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins")
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins")
end
task.wait(cooldown) --task.wait() is heartbeat based and accurate
debounce = true
end
end)
delta time code:
--code
local last = 0
local cooldown = 0.5 --change to whatever you want
script.Parent.MouseButton1Click:Connect(function()
if os.clock() - last >= cooldown then
last = os.clock()
local hasShinyBoost = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21797590) -- check pass
if hasShinyBoost then
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
else
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins")
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins")
end
end
end)
If im correct,tick is also based on your time zone.
Yes. it’s totally based on local time. But, then again, that won’t really make a difference in this scenario.
There is no reason to reply. the post creator has probably not visited the site since the day of publication, the only thing you are doing is creating an additional post, as previous people have already shown that he can use such a thing as a “solution”
I was talking about the debounce issue? All OP needed to do was rearrange a few lines of code.
OP's Code
local plr = script.Parent.Parent.Parent.Parent.Parent
local getMulti = require(game.ServerScriptService.Modules.PetHandler.PetMultiplier)
local shash = 0
local plus = getMulti:GetPetMultipliers(plr, "Coins")
local debounce = true
local cooldown = 0.5
script.Parent.MouseButton1Click:Connect(function()
if debounce == true then
local hasShinyBoost = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21797590) -- check pass
if hasShinyBoost then
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
else
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins")
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins")
debounce = false
wait(cooldown)
debounce = true
end
end
end)
Fixed Code
local plr = script.Parent.Parent.Parent.Parent.Parent
local getMulti = require(game.ServerScriptService.Modules.PetHandler.PetMultiplier)
local shash = 0
local plus = getMulti:GetPetMultipliers(plr, "Coins")
local debounce = true
local cooldown = 0.5
script.Parent.MouseButton1Click:Connect(function()
if debounce == true then
debounce = false;
local hasShinyBoost = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 21797590) -- check pass
if hasShinyBoost then
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins") * 2
else
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins")
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins")
end
wait(cooldown);
debounce = true;
end
end)
if you weren’t talking about debounce. sorry but you are probably in the wrong post.
Exactly how it should be fixed as I posted lol. I’m not sure why this has 55 replies, but hey
I’ve tested it, but there is no difference in the code, it doesn’t work as it’s intended to work, are you sure you got this right? Have you tested your code?
+There are some lines of code that need to be changed/added, it doesn’t really make sense to just remove “local” from it.
If you are testing it and you get results from this exact lines of codes
else
plr.Stats.Coins.Value = plr.Stats.Coins.Value + getMulti:GetPetMultipliers(plr, "Coins")
plr.MiniStats.TotalCoins.Value = plr.MiniStats.TotalCoins.Value + getMulti:GetPetMultipliers(plr, "Coins")
debounce = false
wait(cooldown)
debounce = true
end
yes, it will work, but that’s not a fix to the script, it will also work the same as having “local” in your debounce. Correct me if I’m wrong, I’m just trying to help you understand at the moment, unless once again, I’m wrong.
It didn’t work because regardless of putting local
outside or inside the function, it won’t make any difference because if a variable is localized outside of a function, the function still has access to it.
It’s sort of stupid to read some of these replies. Going to see if I can find somewhat of a solution with actual test results.
The owner is so bad he waste all our time on a super dumb question and everyone gave him the correct solution and he just ignore everyone without even setting solutions!