Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local lp = Players.LocalPlayer
- -- pick the right chat service depending on game version
- local TextChatService = game:GetService("TextChatService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local MESSAGE = "Tafuta kazi"
- local DELAY = 0.15 -- seconds between sends; raise this if you get rate-limited
- -- modern chat (TextChatService)
- local function sendModern()
- local channels = TextChatService:FindFirstChild("TextChannels")
- if not channels then return false end
- local general = channels:FindFirstChild("RBXGeneral")
- if not general then return false end
- general:SendAsync(MESSAGE)
- return true
- end
- -- legacy chat fallback (older games using say message remote)
- local function sendLegacy()
- local chatEvents = ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
- if not chatEvents then return false end
- local sayMessage = chatEvents:FindFirstChild("SayMessageRequest")
- if not sayMessage then return false end
- sayMessage:FireServer(MESSAGE, "All")
- return true
- end
- -- pick which path to use once
- local useModern = TextChatService.ChatVersion == Enum.ChatVersion.TextChatService
- -- core loop — runs until the script is killed (leaving the server kills it)
- task.spawn(function()
- while true do
- local ok = false
- if useModern then
- ok = sendModern()
- if not ok then ok = sendLegacy() end
- else
- ok = sendLegacy()
- if not ok then ok = sendModern() end
- end
- if not ok then
- -- neither chat system found; wait a beat and retry
- task.wait(0.5)
- else
- task.wait(DELAY)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment