Hi all!
I’ve been working my in-game Police Computer (MDT).
I have it set up so that when a player utilizes the Cell Phone, they’re able to send an emergency call. When sending the emergency call, all the information goes through the server and is supposed to end up at the MDT.
The MDT has a scrolling frame named CallList, call list is supposed to update and have a text button pop up for each call and each call has a specific case number so when a player clicks the specific call, it should populate the “CallInfo” frame. The issue I’m experiencing is that even though the call is successfully made and the output shows everything going as planned, no matter what I’ve tried, the CallList doesn’t populate with the buttons for the calls. It stays empty, as if the calls can’t be translated to the MDT.
Here is my current code, if anyone could maybe check and see what I’m doing wrong? Also, I did even run my scripts through AI, trying to see if AI could figure out the issues but even when using updated scripts, nothing is popping up.
Any help would be extremely helpful. I think it could be something very small I’m overlooking.
Here is a picture of both GUIs, on the far left is where the call textbutons are supposed to populate.
Below is The CallScript (Client), MDTHandler (Sever) and most recent Output:
local Players = game:GetService("Players")
local callListUpdate = ReplicatedStorage:WaitForChild("MDT_Events"):WaitForChild("CallListUpdate")
-- Get Player and GUI from PlayerGui
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- ✅ Reference GUI from PlayerGui
local mdtGui = playerGui:WaitForChild("MDT_GUI")
local mainFrame = mdtGui:WaitForChild("Main"):WaitForChild("MainFrame")
local callList = mainFrame:WaitForChild("CallList")
local callInfo = mainFrame:WaitForChild("CallInfo")
-- CallInfo Elements
local callerNameText = callInfo:WaitForChild("CallerNameText")
local suspectText = callInfo:WaitForChild("SuspectText")
local locationText = callInfo:WaitForChild("LocationText")
local descriptionText = callInfo:WaitForChild("DescriptionText")
local acceptCallButton = callInfo:WaitForChild("AcceptCallButton")
local closeButton = callInfo:WaitForChild("CloseButton")
-- Ensure UIListLayout Exists
local listLayout = callList:FindFirstChild("UIListLayout") or Instance.new("UIListLayout", callList)
print("✅ MDT CallScript Loaded Successfully.")
-----------------------------------------------------
-- 📡 DEBUGGING FUNCTION (Check GUI Availability)
-----------------------------------------------------
local function verifyGUI()
if not callList then warn("⚠️ ERROR: CallList missing!") return false end
if not callInfo then warn("⚠️ ERROR: CallInfo missing!") return false end
print("✅ GUI Elements Verified!")
return true
end
-----------------------------------------------------
-- 📌 Function to Update Call List
-----------------------------------------------------
local function updateCallList(calls)
print("📡 Received CallListUpdate with", #calls, "calls!") -- Debugging
-- **Check if GUI is available before proceeding**
if not verifyGUI() then return end
-- **Clear existing CallList**
for _, button in ipairs(callList:GetChildren()) do
if button:IsA("TextButton") then
button:Destroy()
end
end
-- **Check if calls are empty**
if #calls == 0 then
print("🚨 No active calls to display.")
return
end
-- **Process Calls**
for _, call in ipairs(calls) do
print("🔹 Adding Call:", call.caseNumber, "Service:", call.service, "Caller:", call.caller)
local callButton = Instance.new("TextButton")
callButton.Size = UDim2.new(1, 0, 0, 40)
callButton.Text = os.date("%m/%d/%Y @ %I:%M %p", os.time()) .. " - " ..
(call.service == "Police" and "POLICE - " or "FIRE - ") .. call.caseNumber
callButton.TextColor3 = Color3.fromRGB(255, 255, 255)
callButton.BackgroundColor3 = call.service == "Police" and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(255, 0, 0)
callButton.Parent = callList
-- Debugging: Confirm button creation
print("✅ Created Call Button:", callButton.Text)
-- Clicking the button populates CallInfo
callButton.MouseButton1Click:Connect(function()
print("📌 Displaying Call Details:", call.caseNumber)
callerNameText.Text = "Caller: " .. call.caller
suspectText.Text = "Suspect: " .. (call.suspect or "N/A")
locationText.Text = "Location: " .. call.location
descriptionText.Text = "Description: " .. call.description
acceptCallButton.Visible = true
closeButton.Visible = true
callInfo.Visible = true
end)
end
-- ✅ Fix UIListLayout Scaling Issue
callList.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y)
end
-----------------------------------------------------
-- 📌 **LISTEN FOR SERVER EVENTS**
-----------------------------------------------------
callListUpdate.OnClientEvent:Connect(function(calls)
print("📡 Received CallListUpdate from server.") -- Debugging
updateCallList(calls)
end)
-----------------------------------------------------
-- 📌 Close Call Info
-----------------------------------------------------
closeButton.MouseButton1Click:Connect(function()
callInfo.Visible = false
print("📌 CallInfo closed.")
end)
The MDTHandler - Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local submitEmergency = ReplicatedStorage:WaitForChild("MDT_Events"):WaitForChild("SubmitEmergencyCall")
local callListUpdate = ReplicatedStorage:WaitForChild("MDT_Events"):WaitForChild("CallListUpdate")
local caseNumbers = { Police = 0, Fire = 0 } -- Track case numbers
local activeCalls = {} -- Store active calls
-- Debugging: Verify script is running
print("✅ MDTHandler Loaded & Running...")
-----------------------------------------------------
-- 📞 Function to Handle Emergency Calls
-----------------------------------------------------
submitEmergency.OnServerEvent:Connect(function(player, callData)
-- ✅ Confirm incoming call
print("📞 Emergency received from:", player.Name)
-- Generate a unique case number
local year = os.date("%Y")
if callData.service == "Police" then
caseNumbers.Police += 1
callData.caseNumber = "LE" .. year .. string.format("%04d", caseNumbers.Police)
elseif callData.service == "Fire" then
caseNumbers.Fire += 1
callData.caseNumber = "FD" .. year .. string.format("%04d", caseNumbers.Fire)
else
warn("⚠️ Unknown service type:", callData.service)
return
end
-- ✅ Add call to activeCalls
table.insert(activeCalls, callData)
-- ✅ Debugging: Print the full list of active calls
print("🚨 Active Calls List:")
for i, call in ipairs(activeCalls) do
print(" 🔹 Call #" .. i, "Case:", call.caseNumber, "Service:", call.service, "Caller:", call.caller)
end
-- ✅ Send CallListUpdate to all clients
print("📡 Sending CallListUpdate to clients with", #activeCalls, "active calls!")
for _, otherPlayer in ipairs(Players:GetPlayers()) do
callListUpdate:FireClient(otherPlayer, activeCalls)
print("📡 CallListUpdate sent to:", otherPlayer.Name)
end
end)
The Output:
09:22:38.967 📞 Emergency received from: WhiteTuxGroom - Server - NewMDTHandler:46
09:22:38.967 🚨 Active Calls List: - Server - NewMDTHandler:61
09:22:38.968 LE20250001 Police WhiteTuxGroom dw dw dw - Server - NewMDTHandler:63
09:22:38.968 📡 Sending CallListUpdate to clients with 1 active calls! - Server - NewMDTHandler:70
09:22:38.968 📡 CallListUpdate sent to: WhiteTuxGroom - Server - NewMDTHandler:75
09:22:40.366 MDT GUI enabled for: PoliceDept - Client - EquipMDT:11```