Advertisement
qsenko1

SwordShop Prototype

Jul 5th, 2022
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.64 KB | None | 0 0
  1.                                             -- Local Script
  2.                                             -- Made By Ninaflexing123 or Qsenko29!!
  3. local TweenService = game:GetService("TweenService")  
  4. local UI = script.Parent
  5. local ShopButton = script.Parent.ButtonsFrame.SwordShopButton
  6. local Shop = script.Parent.ShopFrame
  7. local ShopBuyFrame = UI.PurchaseFrame
  8. local ShopFrameBuyButton = ShopBuyFrame.BuyButton
  9. local Player = game.Players.LocalPlayer
  10. local SwordBuy = game.ReplicatedStorage.ImportantEvents.SwordBuy
  11. local ShopOpenSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["Among us - Click - Sound Effect"]
  12. local SwordSelectEffect = Player.PlayerGui:WaitForChild("LocalSounds")["coin_pickup_1"]
  13. local CloseEffect = Player.PlayerGui:WaitForChild("LocalSounds")["Button Click sound"]
  14. local PurchaseSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["COINS!!!"]
  15. local EquipSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["Knife Equip"]
  16. local NoSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["no! sound effect"]
  17.  
  18. UI.Enabled = true
  19.  
  20. local ButtonNames = {"ImageButton1","ImageButton2","ImageButton3","ImageButton4","ImageButton5","ImageButton6",
  21.     "ImageButton7","ImageButton8","ImageButton9","ImageButton10","ImageButton11","ImageButton12","ImageButton13",
  22.     "ImageButton14","ImageButton15","ImageButton16"
  23. }
  24.  
  25. print(ButtonNames)
  26.  
  27. local tweenInfo = TweenInfo.new(
  28.     .5, -- Time in seconds
  29.     Enum.EasingStyle.Quad, --"Quad", -- Easing Style
  30.     Enum.EasingDirection.Out, --"Out", -- Easing Direction
  31.     0 -- Override any other tweens)
  32. )  
  33.  
  34. local goal1 = {Position = UDim2.new(0.249, 0,0.26, 0)} 
  35. local ShopTween1 = TweenService:Create(Shop, tweenInfo, goal1)
  36. local goal2 = {Position = UDim2.new(0.249, 0,-0.6, 0)} 
  37. local ShopTween2 = TweenService:Create(Shop, tweenInfo, goal2)
  38. local ShopOpenFunction
  39. local Test
  40. local BuyButtonInfo
  41. local PurchaseCleanup
  42. local PurchaseDebounce = true
  43. local debounce = true
  44.  
  45. SwordBuy.OnClientEvent:Connect(function(Name,Song)
  46.     print(Name)
  47.  
  48.     print(Song)
  49.     if EquipSoundEffect.Name == Song then
  50.         EquipSoundEffect:Play()
  51.     elseif PurchaseSoundEffect.Name == Song then
  52.         PurchaseSoundEffect:Play()
  53.     end
  54. end)
  55.  
  56. -- Get Sword Names
  57.  
  58. for i,TextNames in pairs(Shop.ScrollingFrame.Frame:GetDescendants()) do
  59.     if TextNames:IsA("TextLabel") and TextNames.Name == "SwordName" then
  60.         --  print("names found")
  61.         --  print(TextNames)
  62.         TextNames.Text = tostring(TextNames.Parent.TextName.Value)
  63.     end
  64. end
  65.  
  66. -- Get Sword Prices
  67.  
  68. for i,TextPrices in pairs(Shop.ScrollingFrame.Frame:GetDescendants()) do
  69.     if TextPrices:IsA("TextLabel") and TextPrices.Name == "SwordPrice" then
  70.         TextPrices.Text = "Coins: " .. TextPrices.Parent.TextPrice.Value
  71.     end
  72. end
  73.  
  74. for i,ButtonTextNames in pairs(ButtonNames) do
  75.     --print(ButtonTextNames)
  76.     for i,SwordButtons in pairs(Shop.ScrollingFrame.Frame:GetChildren()) do
  77.         if SwordButtons:IsA("ImageButton") and SwordButtons.Name == ButtonTextNames then
  78.             --  print(ButtonTextNames)
  79.             -- do other stuff!!
  80.             --  print(SwordButtons)
  81.             --      SwordButtons:FindFirstChild("Name").Value = SwordButtons:FindFirstChild("Name").Value
  82.             PurchaseCleanup = SwordButtons.MouseButton1Click:Connect(function()
  83.                 if PurchaseDebounce then
  84.                     PurchaseDebounce = false   
  85.                     --  print(SwordButtons.Name)
  86.                     --  print(ButtonTextNames)
  87.                     if Player.SwordValues:FindFirstChild(SwordButtons.TextName.Value).Value == false then
  88.                         SwordSelectEffect:Play()
  89.                         ShopBuyFrame.Visible = true
  90.                         Shop.Visible = false
  91.                         ShopBuyFrame:TweenPosition(
  92.                             UDim2.new(0.3, 0,0.26, 0),
  93.                             "Out", -- Easing Direction
  94.                             "Quad", -- Easing Style
  95.                             0.25, -- Time in seconds
  96.                             false -- Override any other tweens
  97.                         )
  98.                         ShopBuyFrame.DescriptionLabel.Text = "Are you sure you wanna buy this " .. SwordButtons.TextName.Value .. " for " .. SwordButtons.TextPrice.Value .. " Coins"
  99.                         PurchaseCleanup:Disconnect()
  100.                     else
  101.                         print("Sword Owned Firing Remote to check") -- Firing an Event to check if player owns the sword
  102.                         local Price = SwordButtons:FindFirstChild("TextPrice").Value
  103.                         local Name = SwordButtons:FindFirstChild("TextName").Value 
  104.                         SwordBuy:FireServer(Price,Name)            
  105.                         PurchaseCleanup:Disconnect()
  106.                     end
  107.                     task.wait(.5)      
  108.  
  109.                     PurchaseCleanup:Disconnect()
  110.                     PurchaseDebounce = true    
  111.                 end        
  112.                 BuyButtonInfo = ShopFrameBuyButton.MouseButton1Click:Connect(function()    
  113.                     ShopBuyFrame:TweenPosition(
  114.                         UDim2.new(0.3, 0,-0.6, 0),
  115.                         "Out", -- Easing Direction
  116.                         "Quad", -- Easing Style
  117.                         0.25, -- Time in seconds
  118.                         false -- Override any other tweens
  119.                     )
  120.                     wait(0.25)
  121.                     ShopBuyFrame.Visible = false
  122.                     Shop.Visible = true
  123.                     print(SwordButtons.Name)
  124.                     print(Player.SwordValues:FindFirstChild(tostring(SwordButtons.TextName.Value)))
  125.                     if Player.leaderstats["Coins 💰"].Value >= SwordButtons:FindFirstChild("TextPrice").Value and Player.SwordValues:FindFirstChild(tostring(SwordButtons.TextName.Value)).Value == false then
  126.                         --fire remote event
  127.                         local Price = SwordButtons:FindFirstChild("TextPrice").Value
  128.                         local Name = SwordButtons:FindFirstChild("TextName").Value 
  129.                         print(Price)
  130.                         print(Name)
  131.                         SwordBuy:FireServer(Price,Name)
  132.                     elseif Player.leaderstats["Coins 💰"].Value < SwordButtons:FindFirstChild("TextPrice").Value and Player.SwordValues:FindFirstChild(tostring(SwordButtons.TextName.Value)).Value == false then
  133.                         --  print(SwordButtons:FindFirstChild("SwordPrice").Text)
  134.                         NoSoundEffect:Play()
  135.                         SwordButtons = SwordButtons:FindFirstChild("TextPrice").Parent
  136.                         local buttonPrice = SwordButtons:FindFirstChild("TextPrice").Value
  137.                         print(buttonPrice)
  138.                         local Text = SwordButtons:FindFirstChild("SwordPrice").Text
  139.                         SwordButtons:FindFirstChild("SwordPrice").Text = "Not Enough Coins"
  140.                         task.wait(.5)
  141.                         SwordButtons:FindFirstChild("SwordPrice").Text = "Coins: " .. SwordButtons:FindFirstChild("TextPrice").Value --Text
  142.                         BuyButtonInfo:Disconnect()
  143.                     end
  144.                     PurchaseDebounce= true
  145.                     BuyButtonInfo:Disconnect()
  146.                 end)
  147.             end)
  148.         end
  149.     end
  150. end
  151.  
  152. UI.PurchaseFrame.ExitButton.MouseButton1Click:Connect(function()
  153.     CloseEffect:Play()
  154.     ShopBuyFrame:TweenPosition(
  155.         UDim2.new(0.3, 0,-0.6, 0),
  156.         "Out", -- Easing Direction
  157.         "Quad", -- Easing Style
  158.         0.25, -- Time in seconds
  159.         false -- Override any other tweens
  160.     )
  161.     wait(0.25)
  162.     PurchaseDebounce = true
  163.     ShopBuyFrame.Visible = false
  164.     Shop.Visible = true
  165.     PurchaseCleanup:Disconnect()
  166.     BuyButtonInfo:Disconnect() -- << -- stuff that overlapped this was the solution
  167. end)
  168.  
  169. ShopOpenFunction = ShopButton.MouseButton1Click:Connect(function()
  170.     if Shop.Visible and PurchaseDebounce then
  171.     ShopOpenSoundEffect:Play()
  172.     --[[Shop:TweenPosition(
  173.             UDim2.new(0.249, 0,-0.6, 0),
  174.             "Out", -- Easing Direction
  175.             "Quad", -- Easing Style
  176.             1, -- Time in seconds
  177.             false -- Override any other tweens
  178.         )   --]]
  179.  
  180.         for i,buttons in pairs(Shop.ScrollingFrame.Frame:GetChildren())do
  181.             if buttons:IsA("ImageButton") then
  182.                 buttons.Visible = false
  183.                 buttons.Size = UDim2.new(0,0,0,0)
  184.             end
  185.         end
  186.  
  187.         debounce = false
  188.         ShopTween2:Play()
  189.         ShopTween2.Completed:Connect(function()
  190.             Shop.Visible = false
  191.         end)   
  192.         --  Shop.Visible = false   
  193.     elseif not Shop.Visible and PurchaseDebounce then--and not ShopBuyFrame.Position == UDim2.new(0.3, 0,0.26, 0)
  194.         Shop.Visible = true
  195.         ShopTween1:Play()
  196.         ShopOpenSoundEffect:Play()
  197.     --[[    Shop:TweenPosition(
  198.             UDim2.new(0.249, 0,0.26, 0),
  199.             "Out", -- Easing Direction
  200.             "Quad", -- Easing Style
  201.             1, -- Time in seconds
  202.             false -- Override any other tweens
  203.             --nil
  204.         )--]]
  205.  
  206.         for i,buttons in pairs(Shop.ScrollingFrame.Frame:GetChildren())do
  207.             if buttons:IsA("ImageButton") then
  208.                 buttons.Size = UDim2.new(0,0,0,0)
  209.                 buttons.Visible = true
  210.             end
  211.         end
  212.  
  213.         Test = ShopTween1.Completed:Connect(function()
  214.             --  print("completed") 
  215.             if Shop.Position == UDim2.new(0.249, 0,0.26, 0) then
  216.                 -- print("shop has landed")
  217.                 Shop.ScrollingFrame.Frame.ImageButton1:TweenSize(
  218.                     UDim2.new(0.2, 0,0.101, 0),
  219.                     "Out", -- Easing Direction
  220.                     "Quad", -- Easing Style
  221.                     0.05, -- Time in seconds
  222.                     false -- Override any other tweens
  223.                 )
  224.                 debounce = true
  225.                 wait(0.05)
  226.                 if debounce then
  227.                     Shop.ScrollingFrame.Frame.ImageButton2:TweenSize(
  228.                         UDim2.new(0.2, 0,0.101, 0),
  229.                         "Out", -- Easing Direction
  230.                         "Quad", -- Easing Style
  231.                         0.05, -- Time in seconds
  232.                         false -- Override any other tweens
  233.                     )
  234.                     --          print("idk")
  235.                     wait(0.05)
  236.                     if debounce then --Shop.ScrollingFrame.Frame.ImageButton2.Size == UDim2.new(0.2, 0,0.101, 0) and
  237.                         Shop.ScrollingFrame.Frame.ImageButton3:TweenSize(
  238.                             UDim2.new(0.2, 0,0.101, 0),
  239.                             "Out", -- Easing Direction
  240.                             "Quad", -- Easing Style
  241.                             0.05, -- Time in seconds
  242.                             false -- Override any other tweens
  243.                         )
  244.                         --          print("button2 scalled")
  245.                         wait(0.05)
  246.                         if debounce then
  247.                             Shop.ScrollingFrame.Frame.ImageButton4:TweenSize(
  248.                                 UDim2.new(0.2, 0,0.101, 0),
  249.                                 "Out", -- Easing Direction
  250.                                 "Quad", -- Easing Style
  251.                                 0.05, -- Time in seconds
  252.                                 false -- Override any other tweens
  253.                             )
  254.                             wait(0.05)
  255.                             if debounce then
  256.                                 Shop.ScrollingFrame.Frame.ImageButton5:TweenSize(
  257.                                     UDim2.new(0.2, 0,0.101, 0),
  258.                                     "Out", -- Easing Direction
  259.                                     "Quad", -- Easing Style
  260.                                     0.05, -- Time in seconds
  261.                                     false -- Override any other tweens
  262.                                 )
  263.                                 wait(0.05)
  264.                                 if debounce then
  265.                                     Shop.ScrollingFrame.Frame.ImageButton6:TweenSize(
  266.                                         UDim2.new(0.2, 0,0.101, 0),
  267.                                         "Out", -- Easing Direction
  268.                                         "Quad", -- Easing Style
  269.                                         0.05, -- Time in seconds
  270.                                         false -- Override any other tweens
  271.                                     )
  272.                                     wait(0.05)                             
  273.                                     if debounce then
  274.                                         Shop.ScrollingFrame.Frame.ImageButton7:TweenSize(
  275.                                             UDim2.new(0.2, 0,0.101, 0),
  276.                                             "Out", -- Easing Direction
  277.                                             "Quad", -- Easing Style
  278.                                             0.05, -- Time in seconds
  279.                                             false -- Override any other tweens
  280.                                         )
  281.                                         wait(0.05)                             
  282.                                         if debounce then
  283.                                             Shop.ScrollingFrame.Frame.ImageButton8:TweenSize(
  284.                                                 UDim2.new(0.2, 0,0.101, 0),
  285.                                                 "Out", -- Easing Direction
  286.                                                 "Quad", -- Easing Style
  287.                                                 0.05, -- Time in seconds
  288.                                                 false -- Override any other tweens
  289.                                             )
  290.                                             wait(0.05)                             
  291.                                             if debounce then
  292.                                                 Shop.ScrollingFrame.Frame.ImageButton9:TweenSize(
  293.                                                     UDim2.new(0.2, 0,0.101, 0),
  294.                                                     "Out", -- Easing Direction
  295.                                                     "Quad", -- Easing Style
  296.                                                     0.05, -- Time in seconds
  297.                                                     false -- Override any other tweens
  298.                                                 )
  299.                                                 wait(0.05)                             
  300.                                                 if debounce then
  301.                                                     Shop.ScrollingFrame.Frame.ImageButton10:TweenSize(
  302.                                                         UDim2.new(0.2, 0,0.101, 0),
  303.                                                         "Out", -- Easing Direction
  304.                                                         "Quad", -- Easing Style
  305.                                                         0.05, -- Time in seconds
  306.                                                         false -- Override any other tweens
  307.                                                     )
  308.                                                     wait(0.05)                             
  309.                                                     if debounce then
  310.                                                         Shop.ScrollingFrame.Frame.ImageButton11:TweenSize(
  311.                                                             UDim2.new(0.2, 0,0.101, 0),
  312.                                                             "Out", -- Easing Direction
  313.                                                             "Quad", -- Easing Style
  314.                                                             0.05, -- Time in seconds
  315.                                                             false -- Override any other tweens
  316.                                                         )
  317.                                                         wait(0.05)                             
  318.                                                         if debounce then
  319.                                                             Shop.ScrollingFrame.Frame.ImageButton12:TweenSize(
  320.                                                                 UDim2.new(0.2, 0,0.101, 0),
  321.                                                                 "Out", -- Easing Direction
  322.                                                                 "Quad", -- Easing Style
  323.                                                                 0.05, -- Time in seconds
  324.                                                                 false -- Override any other tweens
  325.                                                             )
  326.                                                             wait(0.05)                             
  327.                                                             if debounce then
  328.                                                                 Shop.ScrollingFrame.Frame.ImageButton13:TweenSize(
  329.                                                                     UDim2.new(0.2, 0,0.101, 0),
  330.                                                                     "Out", -- Easing Direction
  331.                                                                     "Quad", -- Easing Style
  332.                                                                     0.05, -- Time in seconds
  333.                                                                     false -- Override any other tweens
  334.                                                                 )
  335.                                                                 wait(0.05)                             
  336.                                                                 if debounce then
  337.                                                                     Shop.ScrollingFrame.Frame.ImageButton14:TweenSize(
  338.                                                                         UDim2.new(0.2, 0,0.101, 0),
  339.                                                                         "Out", -- Easing Direction
  340.                                                                         "Quad", -- Easing Style
  341.                                                                         0.05, -- Time in seconds
  342.                                                                         false -- Override any other tweens
  343.                                                                     )
  344.                                                                     wait(0.05)                             
  345.                                                                     if debounce then
  346.                                                                         Shop.ScrollingFrame.Frame.ImageButton15:TweenSize(
  347.                                                                             UDim2.new(0.2, 0,0.101, 0),
  348.                                                                             "Out", -- Easing Direction
  349.                                                                             "Quad", -- Easing Style
  350.                                                                             0.05, -- Time in seconds
  351.                                                                             false -- Override any other tweens
  352.                                                                         )
  353.                                                                         wait(0.05)                             
  354.                                                                         if debounce then
  355.                                                                             Shop.ScrollingFrame.Frame.ImageButton16:TweenSize(
  356.                                                                                 UDim2.new(0.2, 0,0.101, 0),
  357.                                                                                 "Out", -- Easing Direction
  358.                                                                                 "Quad", -- Easing Style
  359.                                                                                 0.05, -- Time in seconds
  360.                                                                                 false -- Override any other tweens
  361.                                                                             )
  362.                                                                         end
  363.                                                                     end
  364.                                                                 end
  365.                                                             end
  366.                                                         end
  367.                                                     end
  368.                                                 end
  369.                                             end
  370.                                         end
  371.                                     end
  372.                                 end
  373.                             end
  374.                         end
  375.                     end
  376.                 end
  377.             end
  378.             Test:Disconnect() -- Disconnecting when the shop gets closet just in case and performance!!
  379.             --ShopOpenFunction:Disconnect()
  380.         end)
  381.     end
  382. end)
  383.  
  384. -- Server Script
  385.  
  386. local SwordBuy = game:GetService("ReplicatedStorage").ImportantEvents.SwordBuy
  387.  
  388. SwordBuy.OnServerEvent:Connect(function(Player,Price,Name)
  389.     print("Price is " .. Price .. " and name " ,Name)
  390.     print(Price)
  391.     print(Name)
  392.     if Player.SwordValues:FindFirstChild(Name).Value == false then
  393.         print("Sword Not Owned " .. Name)
  394.         if Player.leaderstats["Coins 💰"].Value >= Price then
  395.             print("Purchasing New Sword" .. Name)
  396.             Player.leaderstats["Coins 💰"].Value = Player.leaderstats["Coins 💰"].Value - Price
  397.             Player.SwordValues:FindFirstChild(Name).Value = true
  398.             -- Auto Equipping the Sword
  399.  
  400.             local Song = "COINS!!!"
  401.             -- firing back
  402.             SwordBuy:FireClient(Player,Name,Song)
  403.                
  404.             for i, tools in pairs(game.ReplicatedStorage.SwordsFolder:GetChildren()) do
  405.                 if tools:IsA("Tool")  then --and tools.Name == Name
  406.                 --  print("works")
  407.                 --  print(tools)
  408.                     if Player.Backpack:FindFirstChild(tools.Name) then
  409.                         if game.ServerStorage:FindFirstChild(Player.Name .. " Storage") then
  410.                             print("Found Another Folder")
  411.                             game.ServerStorage:FindFirstChild(Player.Name .. " Storage"):Destroy()
  412.                             local PlayersStorageFolder = Instance.new("Folder",game.ServerStorage)
  413.                             PlayersStorageFolder.Name = Player.Name .. " Storage"
  414.                             local previoussword = Player.Backpack:FindFirstChild(tools.Name)   
  415.                             local previousItemsFolder = Instance.new("Folder",PlayersStorageFolder)
  416.                             previousItemsFolder.Name = "previousItemsFolder"
  417.                             previoussword.Parent = previousItemsFolder
  418.                             local NewSword = game.ReplicatedStorage.SwordsFolder:FindFirstChild(Name):Clone()
  419.                             NewSword.Parent = Player.Backpack  
  420.                         else
  421.                             print("Tool Found ".. tostring(Player.Backpack:FindFirstChild(tools.Name)))
  422.                             local PlayersStorageFolder = Instance.new("Folder",game.ServerStorage)
  423.                             PlayersStorageFolder.Name = Player.Name .. " Storage"
  424.                             local previoussword = Player.Backpack:FindFirstChild(tools.Name)   
  425.                             local previousItemsFolder = Instance.new("Folder",PlayersStorageFolder)
  426.                             previousItemsFolder.Name = "previousItemsFolder"
  427.                             previoussword.Parent = previousItemsFolder
  428.                             local NewSword = game.ReplicatedStorage.SwordsFolder:FindFirstChild(Name):Clone()
  429.                             NewSword.Parent = Player.Backpack
  430.                         end
  431.                     end
  432.                 end
  433.             end
  434.            
  435.         else
  436.             warn("lier") -- player is most likely hacking
  437.         end
  438.     else
  439.         -- Need to check if player has sword in inventory or not!!
  440.         print("Sword Owned Equipping " .. Name)
  441.         local Song = "Knife Equip"
  442.         -- firing back
  443.         SwordBuy:FireClient(Player,Name,Song)
  444.         for i,Swords in pairs(game.ReplicatedStorage.SwordsFolder:GetChildren()) do
  445.             if Player.Backpack:FindFirstChild(Name) then
  446.                 --  Player.Backpack:FindFirstChild(Name):Destroy()
  447.                 print(Name .. " found")
  448.             end
  449.         end
  450.     end
  451.  
  452. end)   
  453.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement