Sir_Spaceboi

Untitled

Dec 30th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. ----------------- Variables -----------------
  2. local RoomFrame = script.Parent.RoomType
  3. local UserFrame = script.Parent.UserName
  4.  
  5. local SuiteButton = RoomFrame.Suite
  6. local StandardButton = RoomFrame.Standard
  7. local UserNameBox = UserFrame.UserNameBox
  8.  
  9. local RoomFrameClose = RoomFrame.Close
  10. local UserFrameClose = UserFrame.Close
  11.  
  12. local EnterUsernameButton = UserFrame.Enter
  13.  
  14. local UserToGive
  15. local KeyType
  16.  
  17. ----------------- Functions -----------------
  18. local function getPlayerFromPartialName(PartialName)
  19.     local foundName = nil
  20.     local Players = game.Players:GetPlayers()
  21.     for i = 1, #Players do
  22.         local PossiblePlayer = Players[i]
  23.         if string.find(string.lower(PossiblePlayer.Name), string.lower(PartialName)) then
  24.             foundName = PossiblePlayer.Name
  25.         end
  26.     end
  27.  
  28.     if not foundName then
  29.         return nil
  30.     else
  31.         return foundName
  32.     end
  33. end
  34.  
  35. SuiteButton.Activated:Connect(function()
  36.     KeyType = "Suite"
  37.     UserFrame.Visible = true
  38.     RoomFrame.Visible = false
  39. end)
  40.  
  41. StandardButton.Activated:Connect(function()
  42.     KeyType = "Standard"
  43.     UserFrame.Visible = true
  44.     RoomFrame.Visible = false
  45. end)
  46.  
  47. EnterUsernameButton.Activated:Connect(function()
  48.     local UserToGive = getPlayerFromPartialName(UserNameBox.Text)
  49.     print(UserToGive)
  50.    
  51.     UserFrame.Visible = false
  52.     KeyType = KeyType
  53.     game.ReplicatedStorage.GiveRoom:FireServer(KeyType, UserToGive)
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment