Ive been researching proximity chat in roblox and i have a script that works i just need some tweaking.
My script works i just want to implement something to take it the next level and i dont know how. In the video below the further someone is the more transparent the text is. In my script the chat doesnt show up at all once you reach a certain distance. If i could also add the nobody heard you that would help too.
This is my script i just dont know how to implement the transparency and the notification.
local Chat = game:GetService("Chat")
local RunService = game:GetService("RunService")
local ReplicatedModules = Chat:WaitForChild("ClientChatModules")
local ChatSettings = require(ReplicatedModules:WaitForChild("ChatSettings"))
local PROXIMITY_DISTANCE = 50
local function Run(ChatService)
local function WithinProximity(player1, player2)
if player1 == player2 then
return true
end
if player1.Character and player2.Character then
local torso1 = player1.Character:FindFirstChild("Torso")
local torso2 = player2.Character:FindFirstChild("Torso")
if torso1 and torso2 then
return (torso1.Position - torso2.Position).magnitude < PROXIMITY_DISTANCE
end
end
return false
end
local function ProximityChatReplicationFunction(speakerName, message, channelName)
local speakerObj = ChatService:GetSpeaker(speakerName)
local channelObj = ChatService:GetChannel(channelName)
if not speakerObj then return false end
if not channelObj then return false end
local playerObj = speakerObj:GetPlayer()
if not playerObj then return false end
for i, otherSpeakerName in pairs(channelObj:GetSpeakerList()) do
local otherSpeakerObj = ChatService:GetSpeaker(otherSpeakerName)
if otherSpeakerObj then
local otherPlayerObj = otherSpeakerObj:GetPlayer()
if otherPlayerObj then
if WithinProximity(playerObj, otherPlayerObj) then
otherSpeakerObj:SendMessage(message, channelName, speakerName, message.ExtraData)
end
end
end
end
return true
end
ChatService:RegisterProcessCommandsFunction("proximity_chat", ProximityChatReplicationFunction, ChatSettings.LowPriority)
end
return Run