You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want the floor number on the ui to turn red indicating that the room has been taking -
What is the issue? Include screenshots / videos if possible!
so I am making a hotel check-in system in I got it to give me the room key tool but I am having an issue getting the floor number wheatever the room number the player check-in on the ui to turns red that indicates that the room has been taking the room number frames that are supposed to turn red is under the Standard frame but it will not turn red when I check the player in -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried everything I could think of
here’s my GUI script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local addItemToBackpackEvent = ReplicatedStorage:WaitForChild("assignRoomKeyEvent")
local roomStatusEvent = ReplicatedStorage:WaitForChild("RoomStatusEvent")
local CheckInBtn = script.Parent:FindFirstChild("CheckInBtn")
local playerNameTextBox = script.Parent:FindFirstChild("CheckInNAME"):FindFirstChild("TextBox")
local roomNumberTextBox = script.Parent:FindFirstChild("CheckInNUMBER"):FindFirstChild("TextBox")
local ErrorTxt = script.Parent:FindFirstChild("ErrorTxt")
local roomLabels = {}
local standardFrame = script.Parent:FindFirstChild("Standard")
if standardFrame then
for _, frame in ipairs(standardFrame:GetChildren()) do
if frame:IsA("Frame") and frame:FindFirstChildOfClass("TextLabel") then
local roomLabel = frame:FindFirstChildOfClass("TextLabel")
local roomNumber = tonumber(roomLabel.Text)
if roomNumber then
roomLabels[roomNumber] = roomLabel
end
end
end
end
CheckInBtn.MouseButton1Click:Connect(function()
local playerName = playerNameTextBox.Text
local roomNumber = roomNumberTextBox.Text
if playerName == "" or roomNumber == "" then
ErrorTxt.Visible = true
ErrorTxt.Text = "Please enter both player name and room number."
task.delay(1, function()
ErrorTxt.Visible = false
end)
return
end
addItemToBackpackEvent:FireServer(playerName, roomNumber)
end)
addItemToBackpackEvent.OnClientEvent:Connect(function(errorMessage)
if errorMessage then
ErrorTxt.Visible = true
ErrorTxt.Text = errorMessage
task.delay(1, function()
ErrorTxt.Visible = false
end)
end
end)
roomStatusEvent.OnClientEvent:Connect(function(roomNumber, isTaken)
local roomLabel = roomLabels[roomNumber]
if roomLabel then
if isTaken then
roomLabel.TextColor3 = Color3.fromRGB(255, 0, 0) -- Red
else
roomLabel.TextColor3 = Color3.fromRGB(0, 255, 0) -- Green (or any other color for available rooms)
end
end
end)
here my server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local assignRoomKeyEvent = ReplicatedStorage:WaitForChild("assignRoomKeyEvent")
local roomStatusEvent = ReplicatedStorage:WaitForChild("RoomStatusEvent")
local checkedInPlayers = {}
local takenRooms = {}
assignRoomKeyEvent.OnServerEvent:Connect(function(player, playerName, roomNumber)
print("Server: assignRoomKeyEvent received from player:", player.Name, "for playerName:", playerName, "and roomNumber:", roomNumber)
local targetPlayer = Players:FindFirstChild(playerName)
roomNumber = tonumber(roomNumber)
if targetPlayer and targetPlayer.Backpack and roomNumber then
if not checkedInPlayers[playerName] then
local roomKeyFolder = ReplicatedStorage.FreeRooms["Standard Rooms"][tostring(roomNumber)]
if roomKeyFolder then
if not takenRooms[roomNumber] then
local roomKeyTool = roomKeyFolder["Room Key"]:Clone()
roomKeyTool.Parent = targetPlayer.Backpack
checkedInPlayers[playerName] = true
takenRooms[roomNumber] = true
assignRoomKeyEvent:FireClient(player, nil)
roomStatusEvent:FireAllClients(roomNumber, true)
print("Server: Room", roomNumber, "assigned to player", playerName)
else
assignRoomKeyEvent:FireClient(player, "Room is already taken.")
print("Server: Room", roomNumber, "is already taken")
end
else
assignRoomKeyEvent:FireClient(player, "Invalid room number.")
print("Server: Invalid room number", roomNumber)
end
else
assignRoomKeyEvent:FireClient(player, "You have already checked in.")
print("Server: Player", playerName, "has already checked in")
end
else
assignRoomKeyEvent:FireClient(player, "Player not found or invalid room number.")
print("Server: Player not found or invalid room number for playerName:", playerName, "and roomNumber:", roomNumber)
end
end)
for roomNumber, _ in pairs(ReplicatedStorage.FreeRooms["Standard Rooms"]:GetChildren()) do
roomStatusEvent:FireAllClients(tonumber(roomNumber.Name), takenRooms[tonumber(roomNumber.Name)] or false)
print("Server: Initial room status sent for room", roomNumber, "is", takenRooms[tonumber(roomNumber.Name)] or false)
end