I’m having trouble with a skip stage button not sure why its not working I made a kill all button with the same script just different Id’s here is my local script in the textbutton
local plr = game.Players.LocalPlayer
local market = game:GetService("MarketplaceService")
local skipID = 1619494366
script.Parent.MouseButton1Click:Connect(function()
market:PromptProductPurchase(plr, skipID)
end)
here is the script in the serverscriptservice
local players = game:GetService("Players")
local marketplace = game:GetService("MarketplaceService")
local skipID = 1619494366
marketplace.ProcessReceipt = function(receiptinfo)
local plr = players:GetPlayerByUserId(receiptinfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptinfo.ProductId == skipID then
plr.leaderstats.Stage.Value += 1
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
not sure why its not working any help would be appreciated
The script is completelly fine…
Maybe there is another script that is causing the issue. Are there any errors or warnings in the console?
It would be great if you provide us also the kill script and the image of the toolbox where the button, the LocalScript and the ServerScript are stored so we can be able to help you
The issue can be in the LocalScript itself if its parent is another button or is disabled. The same for the ServerScript
Are there multiple types of skip stage buttons in your game? I have noticed that depending on how you run the skip button, it can cause certain skip buttons to stop working.
local players = game:GetService("Players")
local marketplace = game:GetService("MarketplaceService")
local skipID = 1804973481
marketplace.ProcessReceipt = function(receiptinfo)
local plr = players:GetPlayerByUserId(receiptinfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptinfo.ProductId == skipID then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
v.Humanoid.Health = 0
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Since you use .ProcessReceipt twice, once in each script, they are going to conflict with each other. Instead, I would combine the two scripts together like this:
local players = game:GetService("Players")
local marketplace = game:GetService("MarketplaceService")
local skipID = 1804973481
local killAllID = 1619494366
marketplace.ProcessReceipt = function(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == skipID then
-- Handle skipping stage logic
for _, part in ipairs(game.Workspace:GetChildren()) do
if part:FindFirstChild("Humanoid") then
part.Humanoid.Health = 0
end
end
elseif receiptInfo.ProductId == killAllID then
-- Handle killing all players logic
for _, otherPlayer in ipairs(players:GetPlayers()) do
if otherPlayer ~= player then
local humanoid = otherPlayer.Character and otherPlayer.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
I haven’t tested this out, so let me know if it works.
I am not able to test this at the moment, but you could try something like this, and build off of it if necessary:
-- Assume this is a Script in ServerScriptService
-- Load the DataStore service
local DataStoreService = game:GetService("DataStoreService")
local killsDataStore = DataStoreService:GetDataStore("PlayerKills")
-- Function to update player kills
local function updateKills(player)
local playerId = player.UserId
local key = "kills_" .. playerId
local success, currentKills = pcall(function()
return killsDataStore:GetAsync(key)
end)
if success then
currentKills = currentKills or 0
currentKills = currentKills + 1
killsDataStore:SetAsync(key, currentKills)
else
warn("Failed to update kills for player " .. player.Name)
end
end
-- Connect the updateKills function to a kill event
game.Players.PlayerKilled:Connect(function(victim, killer)
if killer and killer:IsA("Player") then
updateKills(killer)
end
end)
-- Function to get the leaderboard data
local function getLeaderboard()
local leaderboard = {}
-- Get all player data from the DataStore
local success, playerData = pcall(function()
return killsDataStore:GetSortedAsync(false, 10) -- Get top 10 players by kills
end)
if success then
for i, entry in ipairs(playerData) do
leaderboard[i] = {
player = game.Players:GetNameFromUserIdAsync(entry.key:split("_")[2]),
kills = entry.value
}
end
else
warn("Failed to fetch leaderboard data")
end
return leaderboard
end
-- Example usage:
local leaderboard = getLeaderboard()
for i, entry in ipairs(leaderboard) do
print(i .. ". " .. entry.player .. ": " .. entry.kills .. " kills")
end