Advertisement
qsenko1

TrailServerScript

Apr 24th, 2021
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. game.ReplicatedStorage.Events.BuyItem.OnServerInvoke = function(player, BluetrailName)
  2.     if debounce == true then
  3.     debounce = false
  4.     print("RemoteFunction fired")
  5.     local ifsInInventory   
  6.     if player.TrailInventory:FindFirstChild("Blue") then
  7.         ifsInInventory = true
  8.     end
  9.  
  10.     if Bluetrail then
  11.         if Bluetrail:FindFirstChild("Price") then
  12.             if not ifsInInventory then
  13.                 -- Check if we can buy the trail
  14.                 if player.leaderstats.Coins.Value >= Bluetrail.Price.Value then
  15.                     print(player.Name.." brought the ".. Bluetrail.Name.." trail")
  16.                     player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - Bluetrail.Price.Value
  17.                     local bool2 = Instance.new("BoolValue",player.TrailInventory); bool2.Name = Bluetrail.Name
  18.                     return "Brought"
  19.                 else
  20.                     return "NotEnough"     
  21.                 end
  22.             else
  23.                 -- You already owned it
  24.                 if player.EquippedTrail.Value ~= Bluetrail.Name and ifsInInventory then                            
  25.                     player.EquippedTrail.Value = Bluetrail.Name
  26.                 --  print(player.Name.." equipped the ".. Bluetrail.Name.." trail")    
  27.                     wait(1)
  28.                     debounce = true
  29.                     return "Equip"                 
  30.                 else                       
  31.                     player.EquippedTrail.Value = ""
  32.                     --print(player.Name.." unequipped the ".. Bluetrail.Name.." trail")
  33.                     wait(1)
  34.                     debounce = true
  35.                     return "Unequip"
  36.                        
  37.                     end        
  38.                 end        
  39.             end
  40.         end
  41.     end
  42.     wait(5)
  43.     debounce = true
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement