Advertisement
hammercoolness

Untitled

Sep 12th, 2024 (edited)
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. -- Services
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local TextChatService = game:GetService("TextChatService")
  5.  
  6. local Player = Players.LocalPlayer
  7. local PlayerGui = Player.PlayerGui
  8.  
  9. -- Configuration
  10. local COOLDOWN_TIME = 30
  11. local ENABLE_CHAT_MESSAGES = true
  12.  
  13. -- Chat Message Function
  14. local function sendChatMessage(message)
  15. if ENABLE_CHAT_MESSAGES then
  16. local player = Players.LocalPlayer
  17. if player then
  18. local textChannel = TextChatService.TextChannels.RBXGeneral
  19. if textChannel then
  20. pcall(function()
  21. textChannel:SendAsync(message)
  22. end)
  23. else
  24. warn("Text channel not found")
  25. end
  26. else
  27. warn("Player not found")
  28. end
  29. end
  30. end
  31.  
  32. -- Function to handle trade acceptance
  33. local function onTradeAccepted()
  34. sendChatMessage("Trade completed")
  35. end
  36.  
  37. -- Connect to the trade acceptance event
  38. ReplicatedStorage.Trade.AcceptTrade.OnClientEvent:Connect(onTradeAccepted)
  39.  
  40. -- Main Loop
  41. while true do
  42. wait()
  43.  
  44. if PlayerGui.MainGUI.Game.Leaderboard.Container.TradeRequest.ReceivingRequest.Visible and PlayerGui.MainGUI.Game.Leaderboard.Container.TradeRequest.Visible then
  45. wait()
  46.  
  47. local sr = PlayerGui.MainGUI.Game.Leaderboard.Container.TradeRequest.ReceivingRequest.Username.Text
  48. local sender = game.Players:FindFirstChild(sr)
  49.  
  50. if sender then
  51. sendChatMessage("Trade with " .. sender.Name .. " started, mode: deposit")
  52. end
  53.  
  54. ReplicatedStorage.Trade.AcceptRequest:FireServer()
  55.  
  56. local Cooldown = 0
  57.  
  58. while wait(1) do
  59. Cooldown = Cooldown + 1
  60.  
  61. local s = PlayerGui.TradeGUI.Container.Trade.TheirOffer.Username.Text
  62. s = string.sub(s, 2, string.len(s) - 1)
  63. local receiver = game.Players:FindFirstChild(s)
  64.  
  65. if not PlayerGui.TradeGUI.Enabled then
  66. break
  67. end
  68.  
  69. if PlayerGui.TradeGUI.Container.Trade.TheirOffer.Accepted.Visible then
  70. -- The trade acceptance is now handled by the OnClientEvent, so no need to call it directly
  71. wait()
  72. break
  73. end
  74.  
  75. if Cooldown > COOLDOWN_TIME then
  76. ReplicatedStorage.Trade.DeclineTrade:FireServer()
  77. sendChatMessage("Trade declined due to timeout.")
  78. break
  79. end
  80. end
  81. end
  82. end
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement