So I have a dev product in my game and when you purchase it it’s supposed to push every player in your server, the script was working perfectly fine in studio local server before but I tried it in actual game and now it sometimes works in local server and then stops working again.
I don’t recall changing the script at all and don’t see anything off so any help is appreciated.
Script
local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local function superPushAll(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.Parent = (v.Character:FindFirstChild("HumanoidRootPart"))
bv.MaxForce = Vector3.new(10000000,10000000,10000000)
bv.Velocity = v.Character.Head.CFrame.LookVector * 200
spawn(function()
wait(0.01)
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"
spawn(function()
wait(3)
z:Destroy()
end)
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
mps.ProcessReceipt = superPushAll
Clip