Trying to send information from the server script to the local script
Server Side Script
local SystemFolder = workspace:WaitForChild("PhoneSystem")
local PhoneGUI = game.ServerStorage.PhoneSystem.PhoneGUI
local ReplicatedStorage = game.ReplicatedStorage
for _, item in SystemFolder:GetChildren() do
if item:IsA("Model") then
local RoomNumber = item.Configuration.Room_Number.Value
local RoomLocation = item.Configuration.Room_Location.Value
-- Sets the Room Number/ Location to the phone screen
item.Screen.SurfaceGui.OwnNumber.Text = "Room: ( "..RoomNumber.." )"
item.Screen.SurfaceGui.Location.Text = "Location: "..RoomLocation
-- Sees if the click detector has been pressed, if so it will clone the UI to the players GUI
item.HitBox.ClickDetector.MouseClick:Connect(function(player)
print("Click detector pressed on phone: "..item.Configuration.Room_Number.Value)
local OpenUI_Event = ReplicatedStorage.PhoneSystem.OpenUI
OpenUI_Event:FireAllClients(player, RoomNumber)
end)
end
end
Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OpenUI = ReplicatedStorage.PhoneSystem.OpenUI
OpenUI.OnClientEvent:Connect(function(player, roomNumber)
print("Received phone number:", roomNumber)
end)