Run it
Copy the script and paste it into your executor.
HttpService = game:GetService("HttpService")
TextChatService = game:GetService("TextChatService")
Players = game:GetService("Players")
LP = Players.LocalPlayer
LastMsg = nil
API_KEY = "YOUR API KEY HERE"
-- get your api key here: https://aistudio.google.com/app/api-keys
MAX_DISTANCE = 15
-- Maximum distance to respond to a player
function Say(text)
text = text:sub(1, 190)
coroutine.(()
(()
TextChatService.TextChannels.RBXGeneral:(text)
)
)()
(player, message)
body = HttpService:({
contents = {{ parts = {{ text = message }} }}
})
ok, res = (()
({
Url = ,
Method = ,
Headers = {
[] = ,
[] = API_KEY
},
Body = body
})
)
ok res res.Body
success, data = (()
HttpService:(res.Body)
)
success data data.candidates data.candidates[] data.candidates[].content data.candidates[].content.parts
text = data.candidates[].content.parts[].text
text
( .. player.DisplayName .. .. text:(, ))
TextChatService.OnBubbleAdded = (msg)
src = msg.TextSource
src src.UserId
plr = Players:(src.UserId)
plr plr == LP
c1, c2 = LP.Character, plr.Character
c1 c2
h1, h2 = c1:(), c2:()
h1 h2 (h1.Position - h2.Position).Magnitude > MAX_DISTANCE
t = msg.Text
t:(, ) == t ==
id = plr.UserId .. .. t
id == LastMsg
LastMsg = id
.(()
(plr, t)
)
--[[ WARNING: Heads up! This script has not been verified by ScriptBlox. Use at your own risk! ]] HttpService = game:GetService("HttpService") TextChatService = game:GetService("TextChatService") Players = game:GetService("Players") LP = Players.LocalPlayer LastMsg = nil API_KEY = "YOUR API KEY HERE" -- get your api key here: https://aistudio.google.com/app/api-keys MAX_DISTANCE = 15 -- Maximum distance to respond to a player function Say(text) text = text:sub(1, 190) coroutine.wrap(function() pcall(function() TextChatService.TextChannels.RBXGeneral:SendAsync(text) end) end)() end function Gemini(player, message) local body = HttpService:JSONEncode({ contents = {{ parts = {{ text = message }} }} }) local ok, res = pcall(function() return request({ Url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent", Method = "POST", Headers = { ["Content-Type"] = "application/json", ["X-goog-api-key"] = API_KEY }, Body = body }) end) if not ok or not res or not res.Body then return end local success, data = pcall(function() return HttpService:JSONDecode(res.Body) end) if success and data and data