Hi developers, i want to make a kick system but i can’t please help me.
What do you want to achieve? I want to make a system that if a player buys a dev product he can enter a username from someone in the server and then that person got kicked
What is the issue? The issue is that i have no idea how to make this
What solutions have you tried so far? I looked on youtube and de developer forum but i can’t find anything.
I’ve made the devproduct and the scripts. But the UI is not showing up. This is my script : ''local MarketplaceService = game:GetService(“MarketplaceService”)
local function ProcessReceipt(receiptInfo)
local player = game:GetService(“Players”):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print(player.Name…“just bought”…receiptInfo.ProductId)
game.Players.PlayerGui.KickSystem.Frame.Visible = true
return Enum.ProductPurchaseDecision.PurchaseGranted
end
I Don’t Use devproducts That Often But Here Is A Script Example
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
--// Change The Numbers With Your Product ID
productFunctions[123456] = function(receipt, player)
player:Kick("Whatever The Reason You Want, Or Just Remove It")
end
local function processReceipt(receiptInfo , PlayerToKick)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:FindFirstChild(PlayerToKick.Name)
if not player then warn("Player Isn't In The Game!") return end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
print("\nProductId:", receiptInfo.ProductId)
print("\nPlayer:", player)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
and In Another script Use PromptProductPurchase --Fix some stuff btw