You need to know basic scripting before you read this tutorial
Also, note that this is a basic tutorial for getting the idea on how to make a hotel system on your own, not a community resource to copy paste, so the design of gui in this tutorial maybe bad, and this is just an idea, so there won’t be much stuff, but shows the basic way for making a hotel system
After reading the tutorial, you will be able to make your custom hotel system like this:
Some words to learn:
- StringValue = An instance(object) value, which have a string as its value
- IntValue = An integer value not decimals
- NumberValue = Any whole number, decimals too
Check in systems:
- Card to open door
2.Open door when touched
These are for opening doors, not for making the check in system
The 2nd one is a bit harder for beginners, if your not a beginner then no worry
Check in system tutorial:
Step 1
Add a Folder in workspace, add string values, with names as room numbers as shown above
Step 2
Add a remote event in ReplicatedStorage for messaging between server and client side
Step 3
Make your gui for check in
Make sure you have a texbox in your gui to enter the player name to give the hotel room key
Step 4
Now we make the thing which sends the message to server to get a room for the player name entered
Add a local script in your button which will give player the room key
Script: (Don’t try to copy paste :D)
script.Parent.MouseButton1Click:Connect(function()
local playerchosen = nil
local haveroomalready = false
local playernameentered = script.Parent.Parent.TextBox.Text:lower()
for i,v in pairs(game.Players:GetPlayers()) do -- checks if a player entered in textbox exist in the server
if v.Name:lower() == playernameentered then -- :lower() means it makes any uppercase letter in the word or sentence a lowercase letter
playerchosen = v -- if a player like that exist in server then we set the player chosen variable as this player
end
end
if playerchosen ~= nil then -- if someone is chosed then do this function below
for i,v in pairs(game.Workspace.Rooms:GetChildren()) do -- this line checks all the room numbers ,if the player owns any room
if v:IsA("StringValue") then
if v.Value == playerchosen.Name then
haveroomalready = true -- this variable changes its value to true, so it means player have room already
end
end
end
if haveroomalready == false then -- if the player don't have a room already then they get a room
game.ReplicatedStorage.GetHotelRoomEvent:FireServer(playerchosen) -- sends message to server
end
end
end)
Step 5
A script in server script service or in workspace, anything is fine
Script:
game.ReplicatedStorage.GetHotelRoomEvent.OnServerEvent:Connect(function(plr,plrtogiveroom)
local roomchosen = nil -- no room is chosen, later it gets chosen
for i,v in pairs(game.Workspace.Rooms:GetChildren()) do
if v.Value == "" then -- this checks if the room is vacant
roomchosen = v -- sets the chosen room to the room which is vacant
end
end
if roomchosen ~= nil then -- if a room is vacant
roomchosen.Value = plrtogiveroom.Name
else
print("No room is vacant") -- it prints no room is vacant if no room is available
end
local tool = Instance.new("Tool",plrtogiveroom.Backpack) -- gives the room key to player
tool.Name = roomchosen.Name.." Room key"
end)
Step 6
Now test it, it works and your happy that you made a hotel system
Now, there is one more thing, you need to remember, check-out rooms and rooms should get vacant if player leaves the server
This one is not hard at all, if you understood how to make this check-in system, you will understand check-out system to
As mentioned, you need to know some basic scripting before watching the tutorial, so I am not telling how to open/close door with the room key you got
Try to do it yourself, its easy and you would be proud that you did something yourself without watching any tutorial
Now to make a check out system
- Add another remote event
- Name it anything you would like to
Script in workspace or server script service:
game.ReplicatedStorage.CheckoutEvent.OnServerEvent:Connect(function(plr,plrtocheckout)
for i,v in pairs(game.Workspace.Rooms:GetChildren()) do -- checks all rooms if player have any room
if v:IsA("StringValue") then
if v.Value == plrtocheckout.Name then -- if room is occupied by the player name
v.Value = "" -- make it vacant
plr.Backpack:ClearAllChildren() -- clears all the stuff in player backpack including hotel key
print("Check-out done")
end
end
end
end)
Step 7
Add check out button to your gui
Also make sure both the text box have different names
Step 8
Add a local script in your textbutton
Script:
This is same like check in system, but a different thing is this is opposite of it
script.Parent.MouseButton1Click:Connect(function()
local playerchosen = nil
local haveroomalready = false
local playernameentered = script.Parent.Parent.TextBox.Text:lower()
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower() == playernameentered then
playerchosen = v
end
end
if playerchosen ~= nil then
for i,v in pairs(game.Workspace.Rooms:GetChildren()) do
if v:IsA("StringValue") then
if v.Value == playerchosen.Name then
haveroomalready = true
end
end
end
if haveroomalready == true then -- if player have room then check out them
game.ReplicatedStorage.CheckoutEvent:FireServer(playerchosen)
end
end
end)
That’s it your done, hotel system check-in, check-out is done, but if you want the room to be vacant when player leaves do this script:
game.Players.PlayerRemoving:Connect(function(plrtocheckout)
for i,v in pairs(game.Workspace.Rooms:GetChildren()) do
if v:IsA("StringValue") then
if v.Value == plrtocheckout.Name then
v.Value = ""
print("Check-out done")
end
end
end
end)
Tutorial is done, some scripts may not have been explained much, but if you know basic scripting thats easy, because I did not do any hard stuff in this tutorial which basic scripters cannot understand
Since its a long tutorial, some people might be bored to see it fully, but I am sure you will know how to make a hotel system for sure
Support me
Hey there, I make alot of tutorials, and if you want to help me please donate below
Paypal