Advertisement
HowToRoblox

CodesScript

Dec 20th, 2019
1,986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. local textBox = script.Parent
  2.  
  3. local code = "Secret Code 123"
  4.  
  5. local codeRedeemed = script.Parent.CodeRedeemed
  6.  
  7. local success = script.Parent.SuccessAudio
  8. local invalid = script.Parent.ErrorAudio
  9.  
  10. textBox.FocusLost:Connect(function(entered, input)
  11.    
  12.     if not entered then return end
  13.    
  14.     local codeEntered = textBox.Text
  15.    
  16.    
  17.     if codeEntered == code then
  18.        
  19.         if codeRedeemed.Value == false then        
  20.            
  21.             codeRedeemed.Value = true
  22.        
  23.             textBox.Text = "Code successfully redeemed!"
  24.             success:Play()
  25.            
  26.             local reward = game.ReplicatedStorage.ClassicSword:Clone()
  27.             reward.Parent = game.Players.LocalPlayer.Backpack
  28.            
  29.         else
  30.            
  31.             textBox.Text = "Already redeemed!"
  32.             invalid:Play() 
  33.         end
  34.        
  35.     else
  36.        
  37.         textBox.Text = "Invalid code!"
  38.         invalid:Play()         
  39.     end
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement