It doesn’t yield.
Hmm…Why you need to yield a debounce ?
do you not see the wait before it turns the boolean to false??
My question is why are you yielding it, like what’s the advantage of it, like it shouldn’t be an extra code, so why to yield a debounce.
I’m not yielding, the original script does, it has two waits.
I’m asking about the debounce yield man -_-
Oh, I see, thanks for clarity. But still, why to use a CollectionService for a debounce ? I’m stuck at this point. I want to know, not criticize. Sorry I’m irritating.
Now that is done, ignore what I posted.
So now I don’t have right to ask a simple question. Great.
Hey, if I helped you, mark as a solution! I just wanted to tell you that I updated my code.
It works but its not displaying the correct amount of currency on the cash button surface gui.
Because you’re looping it so it lags.
local Debounce = false
local MPS = game:GetService("MarketplaceService")
Mainitems.CashButton.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == player then
if Debounce == false then
Debounce = true
if MPS:UserOwnsGamePassAsync(player.UserId, gamepassidhere) then
player:WaitForChild("leaderstats").Tix.Value += Values.CashValue.Value * 2
wait()
Values.CashValue.Value = 0
wait(1)
Debounce = false
else
player:WaitForChild("leaderstats").Tix.Value += Values.CashValue.Value
wait()
Values.CashValue.Value = 0
wait(1)
Debounce = false
end
end
end
end
end)
Value.Changed:Connect(function(value)
Mainitems.CashButton.ScreenPart.SurfaceGui.TextLabel.Text = value
end)
Getting this error: Workspace.Tycoons.TycoonModel.Scripts.MainScript:137: attempt to index nil with ‘Changed’ - Server - MainScript:137
SurfaceGui is broken
Dude, put the name of the value as the value you have. Don’t totally copy my code.
Change the value where. Still getting an error.
*Gui is working but not displaying the correct amount. Does not display the *2
Dude, just do it like Value * 2
local Debounce = false
local MPS = game:GetService("MarketplaceService")
Mainitems.CashButton.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == player then
if Debounce == false then
Debounce = true
if MPS:UserOwnsGamePassAsync(player.UserId, gamepassidhere) then
player:WaitForChild("leaderstats").Tix.Value += Values.CashValue.Value * 2
wait()
Values.CashValue.Value = 0
wait(1)
Debounce = false
else
player:WaitForChild("leaderstats").Tix.Value += Values.CashValue.Value
wait()
Values.CashValue.Value = 0
wait(1)
Debounce = false
end
end
end
end
end)
Value.Changed:Connect(function(value)
Mainitems.CashButton.ScreenPart.SurfaceGui.TextLabel.Text = value * 2
end)
That isnt what i said, never said anything about saving the gamepass with datastores, i said to use an attribute or value to save if they own it once they join, just for that game
I never claimed you said about DataStores. i just told why attributes aren’t a good idea.