I made a kill everyone dev product and remembered that hackers/executors can fire remote events. How can I optimize my scripts so hackers can’t kill everyone for free and ruin the game for others?
Local Script inside a Text Button:
local Id = 0
local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local Event = game.ReplicatedStorage.Events
local KillEveryoneEvent = Event.KillEveryoneEvent
local Info = mps:GetProductInfo(Id, Enum.InfoType.Product)
script.Parent.MouseButton1Down:Connect(function()
mps:PromptProductPurchase(plr, Id)
end)
mps.PromptProductPurchaseFinished:Connect(function(player, gpsid, purchased)
if gpsid == Id and purchased then
KillEveryoneEvent:FireServer(plr)
end
end)
Server Script inside ServerScriptService:
local KillAllEvent = game.ReplicatedStorage.Events.KillAllEvent
local KillAllMessageEvent = game.ReplicatedStorage.Events.KillAllMessageEvent
local Folder = game.Workspace.Checkpoints
local MaxLevel = #Folder:GetChildren()
KillAllEvent.OnServerEvent:Connect(function(player)
KillAllMessageEvent:FireAllClients({Text = player.DisplayName .. " (@" .. player.Name ..")" .. " has Killed Everyone!", Color = Color3.new(1, 0, 0), Font = Enum.Font.SourceSansBold, FontSize = Enum.FontSize.Size24})
for i,v in pairs(game.Players:GetPlayers()) do
if (v.UserId ~= player.UserId and v.Character and v.Character:FindFirstChild("Humanoid")) then
v.Character:FindFirstChild("Humanoid").Health = 0
end
end
end)
Local Script inside StarterPlayerScripts:
game.ReplicatedStorage.Events.KillEveryoneMessageEvent.OnClientEvent:Connect(function(chatProperties) --Recieves the event sent from the player (excluding the player argument if we used :FireClient()
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", chatProperties) --Outputs the message to the client’s chat window
end)
There’s a value it returns which sees whether or not the player actually bought it. I would highly recommend they use .ProcessReciept instead, because the above method is not at all secure.
Just did some research and according to roblox docs:
“A callback to process receipts of developer product purchases. This callback should be set once and only once by a single Script. If you’re selling multiple products in your experience, this callback should handle receipts for all of them.”
Does this mean I can only use it for 1 dev product or group all my dev prods in 1 script?