#Radio/walkie-talkie isn't working

1 messages · Page 1 of 1 (latest)

kindred elk
#

Players hold a Radio Tool.

When a player sends a chat message while holding the Radio Tool, that message is intercepted.

It's supposed to show as a bubble chat above the radio tool to other nearby players who are also holding the Radio Tool.

Here's the script:


local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local LocalPlayer = Players.LocalPlayer


local MAX_DISTANCE = 50
local REQUIRED_TOOL_NAME = "Radio"


local function hasRadioEquipped(player)
    local character = player.Character
    if not character then return false end

    local tool = character:FindFirstChildOfClass("Tool")
    return tool and tool.Name == REQUIRED_TOOL_NAME
end


TextChatService.OnIncomingMessage = function(message)
    local speaker = Players:GetPlayerByUserId(message.TextSource.UserId)
    if not speaker then return end

    local speakerChar = speaker.Character
    local listenerChar = LocalPlayer.Character
    if not (speakerChar and listenerChar) then return end

    if not (hasRadioEquipped(speaker) and hasRadioEquipped(LocalPlayer)) then
        message:Destroy()
        return
    end

    local speakerHRP = speakerChar:FindFirstChild("HumanoidRootPart")
    local listenerHRP = listenerChar:FindFirstChild("HumanoidRootPart")
    if not (speakerHRP and listenerHRP) then return end

    local distance = (speakerHRP.Position - listenerHRP.Position).Magnitude
    if MAX_DISTANCE > 0 and distance > MAX_DISTANCE then return end


    task.defer(function()
        local adornee = speakerChar:FindFirstChild("Head")
        print("Radio message shown!")
        if adornee and adornee:IsDescendantOf(workspace) and speakerChar:IsDescendantOf(workspace) then
            print("Radio message shown!")
            TextChatService:DisplayBubble(message, adornee)
            print("Radio message shown!")
        end
    end)
end

lapis echo
#

@kindred elk did you ever fix?

kindred elk
#

Nope