local Stages = script.Parent:GetChildren()
local StageDifferenceWarningEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("StageDifferenceWarning")
local StageNotificationEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("StageNotification")
local Config = {
StageOnDeath = false;
AntiCheat = true; -- Won't let a player stage on the stage after their next stage
DoubleStagePass = 60560957;
VIPExtraStageChance = 60750478;
}
local ExtraStageChances = {
["Yes"] = 25;
["No"] = 75;
}
local PlrsOnCooldown = {}
local mps = game:GetService("MarketplaceService")
local function ChooseAmountOfStageToSet(UserId)
local TempChanceVerdictTable = {}
local CurrentStagesToSet = 1
if mps:UserOwnsGamePassAsync(UserId, Config.DoubleStagePass) then
CurrentStagesToSet += 1
if mps:UserOwnsGamePassAsync(UserId, Config.VIPExtraStageChance) then
for choice, chance in pairs(ExtraStageChances) do
for i = 1, chance do
table.insert(TempChanceVerdictTable, choice)
end
end
local ChosenVIPExtraStageVerdict = TempChanceVerdictTable[math.random(1,#TempChanceVerdictTable)]
if ChosenVIPExtraStageVerdict == "Yes" then
CurrentStagesToSet += 1
return CurrentStagesToSet
else
return CurrentStagesToSet
end
else
return CurrentStagesToSet
end
else
if mps:UserOwnsGamePassAsync(UserId, Config.VIPExtraStageChance) then
for choice, chance in pairs(TempChanceVerdictTable) do
for i = 1, chance do
table.insert(TempChanceVerdictTable, choice)
end
end
local ChosenVIPExtraStageVerdict = TempChanceVerdictTable[math.random(1,#TempChanceVerdictTable)]
if ChosenVIPExtraStageVerdict == "Yes" then
CurrentStagesToSet += 1
return CurrentStagesToSet
else
return CurrentStagesToSet
end
else
return CurrentStagesToSet
end
end
end
for _, stage in pairs(Stages) do
if stage:IsA("Model") then
stage.Spawn.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local plrhealth = hit.Parent.Humanoid.Health
local CurrentStageNum = tonumber(stage.Num.Value)
if player.leaderstats.Stage.Value < CurrentStageNum and not table.find(PlrsOnCooldown, player.Name) then
if Config.StageOnDeath == false then
if plrhealth > 0 then
if Config.AntiCheat == true then
local StageDifference = (CurrentStageNum - player.leaderstats.Stage.Value)
if StageDifference == 1 then
local AmountOfStagesToGive = ChooseAmountOfStageToSet(player.UserId)
print(AmountOfStagesToGive)
player.leaderstats.Stage.Value = (player.leaderstats.Stage.Value + AmountOfStagesToGive)
StageNotificationEvent:FireClient(player, player.leaderstats.Stage.Value, AmountOfStagesToGive - 1)
else
StageDifferenceWarningEvent:FireClient(player)
end
else
StageDifferenceWarningEvent:FireClient(player)
end
end
else
if Config.AntiCheat == true then
local StageDifference = (CurrentStageNum - player.leaderstats.Stage.Value)
if StageDifference == 1 then
local AmountOfStagesToGive = ChooseAmountOfStageToSet(player.UserId)
player.leaderstats.Stage.Value = (player.leaderstats.Stage.Value + AmountOfStagesToGive)
StageNotificationEvent:FireClient(player, player.leaderstats.Stage.Value, AmountOfStagesToGive - 1)
else
StageDifferenceWarningEvent:FireClient(player)
end
else
StageDifferenceWarningEvent:FireClient(player)
end
end
end
end
end)
end
end
Whenever a player touches the part from stage 1 it fires too many times making someone stage 15
I tried cooldowns but they dont work