Advertisement
NoTextForSpeech

Sell farms at final wave of every gamemode

Sep 20th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. if not game:IsLoaded() then game.Loaded:Wait() end
  2. if game.PlaceId ~= 5591597781 then return end
  3.  
  4. local rf, id, StateReplicatorPath = game.ReplicatedStorage.RemoteFunction, game.Players.LocalPlayer.UserId
  5. for _, v in pairs(game.ReplicatedStorage.StateReplicators:GetChildren()) do
  6. if v:GetAttribute("Wave") then StateReplicatorPath = v break end
  7. end
  8.  
  9. local waves = {Easy = 25, Normal = 40, Intermediate = 30, Fallen = 40, Hardcore = 50}
  10. local FinalWave = waves[game.ReplicatedStorage.State.Difficulty.Value]
  11.  
  12. StateReplicatorPath:GetAttributeChangedSignal("Wave"):Connect(function()
  13. if StateReplicatorPath:GetAttribute("Wave") == FinalWave then
  14. for _, v in ipairs(workspace.Towers:GetChildren()) do
  15. if v.Owner.Value == id and v.Replicator:GetAttribute("Type") == "Farm" then
  16. spawn(function() rf:InvokeServer("Troops", "Sell", {Troop = v}) end)
  17. end
  18. end
  19. end
  20. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement