I can’t seems to figure out why my script isn’t work, if someone could help me, I would appreciate it.
MarketplaceService.ProcessReceipt = function(RecepitInfo)
local Purchasing = Players:GetPlayerByUserId(RecepitInfo.PlayerId)
if Purchasing then
if RecepitInfo.ProductId == 1116126549 then
if Purchasing then
if Boat.MainParts:FindFirstChild("RobuxButton") then
local RobuxButton = Boat.MainParts.RobuxButton
local debRepair = false
RobuxButton.Display.Label.Text = "CLICK TO REPAIR\n["..tostring(stats.RepairWoodCost).." WOOD]"
function RepairShip(Player)
if debRepair then return end
if CurrentHealth >= stats.Health then return end
if Player:FindFirstChild("Stats") and Player.Stats:FindFirstChild("Wood") and Player.Stats.Wood.Value >= stats.RepairWoodCost then
debRepair = true
RobuxButton.Display.Label.Text = "REPAIRING..."
Player.Stats.Wood.Value = Player.Stats.Wood.Value - stats.RepairWoodCost
RobuxButton.Sound:Play()
RobuxButton.ParticleEmitter.Enabled = true
CurrentHealth = math.clamp(CurrentHealth + stats.RepairHealthAmount, 0, stats.Health)
if Boat.Owner.Value and Boat.Owner.Value.Parent and Boat.Owner.Value:FindFirstChild("Ships") then
if Boat.Owner.Value.Ships:FindFirstChild(Boat.ShipType.Value) then
Boat.Owner.Value.Ships[Boat.ShipType.Value].Value = CurrentHealth
end
end
wait(0.1)
RobuxButton.ParticleEmitter.Enabled = false
wait(stats.RepairCooldown)
RobuxButton.Display.Label.Text = "CLICK TO REPAIR\n["..tostring(stats.RepairWoodCost).." WOOD]"
debRepair = false
end
end
RobuxButton.ClickDetector.MouseClick:Connect(RepairShip)
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
PreviousPurchases:IncrementAsync(RecepitInfo.PlayerId .. "_" .. RecepitInfo.ProductId, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end