So I’m trying to make a Roblox script, which let’s players create a tweeter account and then post.
When they say /tweet message, their @ handle which is stored in PlrData.Tweeter.Value is used to create a Blue coloured message which everyone sees in chat.
But for some reason, the function of actually tweeting doesn’t work. No blue message pops up in chat for everyone and I thought this code would work but whatever I do, it doesn’t work.
-- local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("0mixtapes")
local function onChatted(player, message)
local cmd, arg = message:match("^/(%w+) *(.*)")
if cmd == "ctweet" then
player.PlrData.Tweeter.Value = arg
DataStore:SetAsync(player.UserId, arg)
player:Chat("Tweeter account created. Selected username: @" .. arg)
elseif cmd == "deltweet" then
player.PlrData.Tweeter.Value = ""
DataStore:SetAsync(player.UserId, "")
player:Chat("Tweeter account deleted.")
elseif cmd == "tweet" then
local selectedUsername = player.PlrData.Tweeter.Value or DataStore:GetAsync(player.UserId)
if selectedUsername then
local messageToSend = "@" .. selectedUsername .. " says: " .. arg
for _, p in ipairs(Players:GetPlayers()) do
p:Chat(Color3.fromRGB(0, 162, 255), messageToSend)
end
else
player:Chat("Error: You need to create a Tweeter account before you can tweet.")
end
end
end
local function onPlayerAdded(player)
local selectedUsername = DataStore:GetAsync(player.UserId)
if selectedUsername then
player.PlrData.Tweeter.Value = selectedUsername
player:Chat("Welcome back! Your Tweeter username is still set to @" .. selectedUsername)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(function(player)
DataStore:SetAsync(player.UserId, "")
end)
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
onChatted(player, message)
end)
end)
Idk if you need to know this but it’s a non local script inside the ServerScriptService.