I have a developer product that when the player buys it pushes/flings everyone in the server and this script works sometimes then randomly stops working I don’t know if the problem is the script or something else in the game.
Script
local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local function pushAll(reciept)
if (reciept.ProductId == 1366773605) then
for i, v in pairs(game.Players:GetPlayers()) do
if(v.UserId ~= reciept.PlayerId and v.Character and v.Character:FindFirstChild("Humanoid")) then
local bv = Instance.new("BodyVelocity")
local offset = Vector3.new()
bv.MaxForce = Vector3.new(10000000,10000000,10000000)
bv.Velocity = v.Character.Head.CFrame.LookVector * 200
bv.Parent = (v.Character:FindFirstChild("HumanoidRootPart"))
spawn(function()
wait(0.1)
bv:Destroy()
end)
if v.Character:FindFirstChild("Effects") then
if not v.Character.Effects:FindFirstChild("Ragdoll") then
local z = Instance.new("BoolValue", v.Character.Effects)
z.Name = "Ragdoll"
local Debris = game:GetService("Debris")
Debris:AddItem(z, 3)
task.wait(0.1)
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = pushAll
It working