Local Script:
-- Variables
local Player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local RadioFrame = script.Parent
local ActiveChange = RadioFrame.ActiveInactive.ActiveChange
local ChannelChange = RadioFrame.ChannelChangeText.ChannelChange
local ChannelTextLabel = RadioFrame.CurrentChannel.ChannelTextLabel
local PanicButton = RadioFrame.PanicButton.PanicButton
-- Channel List
local Channels = {"Global","Police","Fire"}
-- Remote Events
local RadioRemoteEvents = game.ReplicatedStorage.RadioRemoteEvents
local RadioEvent = RadioRemoteEvents.RadioEvent
-- Program Global Variables
CurrentChannel = "Global"
Active = false
-- Define New Increment
function DefineNewIncrement(Increment)
local NewIncrement = Increment
if Increment < 3 then
NewIncrement = Increment + 1
elseif Increment >= 3 then
NewIncrement = 1
end
return NewIncrement
end
-- Change Channnel
function ChangeChannel()
local Increment = table.find(Channels,CurrentChannel)
local NewIncrement = DefineNewIncrement(Increment)
CurrentChannel = Channels[NewIncrement]
ChannelTextLabel.Text = "C: "..CurrentChannel
RadioFrame:FindFirstChild(Channels[Increment]).Visible = false
RadioFrame:FindFirstChild(CurrentChannel).Visible = true
end
-- Change Active
local RadioAnimationTrack
local RadioAnimation = script.RadioAnimation
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
function ChangeActive()
if Active == false then
RadioAnimationTrack = hum:LoadAnimation(RadioAnimation)
Active = true
RadioAnimationTrack:Play()
ActiveChange.Text = "(T) Active"
ActiveChange.Parent.ImageColor3 = Color3.fromRGB(255,0,0)
elseif Active == true then
Active = false
RadioAnimationTrack:Stop()
ActiveChange.Text = "(T) Inactive"
ActiveChange.Parent.ImageColor3 = Color3.fromRGB(11,101,107)
end
end
-- User Input Service
UserInputService.InputBegan:Connect(function(Key, IsTyping)
if IsTyping then return end
if Key.KeyCode == Enum.KeyCode.Y then
ChangeChannel()
elseif Key.KeyCode == Enum.KeyCode.T then
ChangeActive()
end
end)
-- Button Function
ChannelChange.MouseButton1Click:Connect(function()
ChangeChannel()
end)
-- Button Function
ActiveChange.MouseButton1Click:Connect(function()
ChangeActive()
end)
PanicButton.MouseButton1Click:Connect(function()
local Message = "**PANIC BUTTON PRESSED**"
local Type = "panic"
RadioEvent:FireServer(Message,CurrentChannel,Type,game.Players.LocalPlayer.Name,game.Players.LocalPlayer.UserId)
end)
-- Player Chatter
Player.Chatted:Connect(function(Message)
if Active == false then return end
local Type = "radio"
RadioEvent:FireServer(Message,CurrentChannel,Type,game.Players.LocalPlayer.Name,game.Players.LocalPlayer.UserId)
end)
Server Script:
local hookURL = ""
local hookURL2 = ""
local httpService = game:GetService("HttpService")
-- Remote Events
local RadioRemoteEvents = game.ReplicatedStorage.RadioRemoteEvents
local RadioEvent = RadioRemoteEvents.RadioEvent
local PanicEvent = RadioRemoteEvents.PanicButton
-- Display Message
function DisplayMessage(FrameToOutput,Message)
FrameToOutput.LineFour.TextLabel.Text = FrameToOutput.LineThree.TextLabel.Text
FrameToOutput.LineThree.TextLabel.Text = FrameToOutput.LineTwo.TextLabel.Text
FrameToOutput.LineTwo.TextLabel.Text = FrameToOutput.LineOne.TextLabel.Text
FrameToOutput.LineOne.TextLabel.Text = Message
end
-- Configure Message
function ConfigMessage(Player,Message,Channel,Type)
print(Message)
print(Channel)
print(Type)
print(Player)
local RadioGui = script.Parent
local FrameToOutput = script.Parent:FindFirstChild(Channel)
local ConfiguredMessage = Player..": "..Message
DisplayMessage(FrameToOutput,ConfiguredMessage)
end
-- Radio Event / On-Server-Event
RadioEvent.OnServerEvent:Connect(function(Player,Message,CurrentChannel,Type)
ConfigMessage(Message,CurrentChannel,Type,Player)
if Type == "panic" then
game.Workspace.PanicButtonSound:Play()
else
game.Workspace.RadioSound:Play()
end
end)
RadioEvent.OnServerEvent:Connect(function(Player,Message,CurrentChannel,Type)
if Type == "panic" then
local data = {
["embeds"] = {
{
["title"] = "Panic Button",
["description"] = "[" .. Player.Name .. "](http://www.roblox.com/users/" .. tostring(Player.UserId) .. "/profile) pressed their panic button!",
["color"] = 7506394
}
}
}
local enData = httpService:JSONEncode(data)
httpService:PostAsync(hookURL,enData)
ConfigMessage(Player.Name,Message,CurrentChannel,Type)
else
local data2 = {
["embeds"] = {
{
["title"] = "Radio Transmission",
["description"] = "[" .. Player.Name .. "](http://www.roblox.com/users/" .. tostring(Player.UserId) .. "/profile) said `".. Message .. "` on the radio!",
["color"] = 7506394
}
}
}
local enData2 = httpService:JSONEncode(data2)
httpService:PostAsync(hookURL2,enData2)
ConfigMessage(Player.Name,Message,CurrentChannel,Type)
end
end)