Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Local Script
- -- Made By Ninaflexing123 or Qsenko29!!
- local TweenService = game:GetService("TweenService")
- local UI = script.Parent
- local ShopButton = script.Parent.ButtonsFrame.SwordShopButton
- local Shop = script.Parent.ShopFrame
- local ShopBuyFrame = UI.PurchaseFrame
- local ShopFrameBuyButton = ShopBuyFrame.BuyButton
- local Player = game.Players.LocalPlayer
- local SwordBuy = game.ReplicatedStorage.ImportantEvents.SwordBuy
- local ShopOpenSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["Among us - Click - Sound Effect"]
- local SwordSelectEffect = Player.PlayerGui:WaitForChild("LocalSounds")["coin_pickup_1"]
- local CloseEffect = Player.PlayerGui:WaitForChild("LocalSounds")["Button Click sound"]
- local PurchaseSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["COINS!!!"]
- local EquipSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["Knife Equip"]
- local NoSoundEffect = Player.PlayerGui:WaitForChild("LocalSounds")["no! sound effect"]
- UI.Enabled = true
- local ButtonNames = {"ImageButton1","ImageButton2","ImageButton3","ImageButton4","ImageButton5","ImageButton6",
- "ImageButton7","ImageButton8","ImageButton9","ImageButton10","ImageButton11","ImageButton12","ImageButton13",
- "ImageButton14","ImageButton15","ImageButton16"
- }
- print(ButtonNames)
- local tweenInfo = TweenInfo.new(
- .5, -- Time in seconds
- Enum.EasingStyle.Quad, --"Quad", -- Easing Style
- Enum.EasingDirection.Out, --"Out", -- Easing Direction
- 0 -- Override any other tweens)
- )
- local goal1 = {Position = UDim2.new(0.249, 0,0.26, 0)}
- local ShopTween1 = TweenService:Create(Shop, tweenInfo, goal1)
- local goal2 = {Position = UDim2.new(0.249, 0,-0.6, 0)}
- local ShopTween2 = TweenService:Create(Shop, tweenInfo, goal2)
- local ShopOpenFunction
- local Test
- local BuyButtonInfo
- local PurchaseCleanup
- local PurchaseDebounce = true
- local debounce = true
- SwordBuy.OnClientEvent:Connect(function(Name,Song)
- print(Name)
- print(Song)
- if EquipSoundEffect.Name == Song then
- EquipSoundEffect:Play()
- elseif PurchaseSoundEffect.Name == Song then
- PurchaseSoundEffect:Play()
- end
- end)
- -- Get Sword Names
- for i,TextNames in pairs(Shop.ScrollingFrame.Frame:GetDescendants()) do
- if TextNames:IsA("TextLabel") and TextNames.Name == "SwordName" then
- -- print("names found")
- -- print(TextNames)
- TextNames.Text = tostring(TextNames.Parent.TextName.Value)
- end
- end
- -- Get Sword Prices
- for i,TextPrices in pairs(Shop.ScrollingFrame.Frame:GetDescendants()) do
- if TextPrices:IsA("TextLabel") and TextPrices.Name == "SwordPrice" then
- TextPrices.Text = "Coins: " .. TextPrices.Parent.TextPrice.Value
- end
- end
- for i,ButtonTextNames in pairs(ButtonNames) do
- --print(ButtonTextNames)
- for i,SwordButtons in pairs(Shop.ScrollingFrame.Frame:GetChildren()) do
- if SwordButtons:IsA("ImageButton") and SwordButtons.Name == ButtonTextNames then
- -- print(ButtonTextNames)
- -- do other stuff!!
- -- print(SwordButtons)
- -- SwordButtons:FindFirstChild("Name").Value = SwordButtons:FindFirstChild("Name").Value
- PurchaseCleanup = SwordButtons.MouseButton1Click:Connect(function()
- if PurchaseDebounce then
- PurchaseDebounce = false
- -- print(SwordButtons.Name)
- -- print(ButtonTextNames)
- if Player.SwordValues:FindFirstChild(SwordButtons.TextName.Value).Value == false then
- SwordSelectEffect:Play()
- ShopBuyFrame.Visible = true
- Shop.Visible = false
- ShopBuyFrame:TweenPosition(
- UDim2.new(0.3, 0,0.26, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.25, -- Time in seconds
- false -- Override any other tweens
- )
- ShopBuyFrame.DescriptionLabel.Text = "Are you sure you wanna buy this " .. SwordButtons.TextName.Value .. " for " .. SwordButtons.TextPrice.Value .. " Coins"
- PurchaseCleanup:Disconnect()
- else
- print("Sword Owned Firing Remote to check") -- Firing an Event to check if player owns the sword
- local Price = SwordButtons:FindFirstChild("TextPrice").Value
- local Name = SwordButtons:FindFirstChild("TextName").Value
- SwordBuy:FireServer(Price,Name)
- PurchaseCleanup:Disconnect()
- end
- task.wait(.5)
- PurchaseCleanup:Disconnect()
- PurchaseDebounce = true
- end
- BuyButtonInfo = ShopFrameBuyButton.MouseButton1Click:Connect(function()
- ShopBuyFrame:TweenPosition(
- UDim2.new(0.3, 0,-0.6, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.25, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.25)
- ShopBuyFrame.Visible = false
- Shop.Visible = true
- print(SwordButtons.Name)
- print(Player.SwordValues:FindFirstChild(tostring(SwordButtons.TextName.Value)))
- if Player.leaderstats["Coins 💰"].Value >= SwordButtons:FindFirstChild("TextPrice").Value and Player.SwordValues:FindFirstChild(tostring(SwordButtons.TextName.Value)).Value == false then
- --fire remote event
- local Price = SwordButtons:FindFirstChild("TextPrice").Value
- local Name = SwordButtons:FindFirstChild("TextName").Value
- print(Price)
- print(Name)
- SwordBuy:FireServer(Price,Name)
- elseif Player.leaderstats["Coins 💰"].Value < SwordButtons:FindFirstChild("TextPrice").Value and Player.SwordValues:FindFirstChild(tostring(SwordButtons.TextName.Value)).Value == false then
- -- print(SwordButtons:FindFirstChild("SwordPrice").Text)
- NoSoundEffect:Play()
- SwordButtons = SwordButtons:FindFirstChild("TextPrice").Parent
- local buttonPrice = SwordButtons:FindFirstChild("TextPrice").Value
- print(buttonPrice)
- local Text = SwordButtons:FindFirstChild("SwordPrice").Text
- SwordButtons:FindFirstChild("SwordPrice").Text = "Not Enough Coins"
- task.wait(.5)
- SwordButtons:FindFirstChild("SwordPrice").Text = "Coins: " .. SwordButtons:FindFirstChild("TextPrice").Value --Text
- BuyButtonInfo:Disconnect()
- end
- PurchaseDebounce= true
- BuyButtonInfo:Disconnect()
- end)
- end)
- end
- end
- end
- UI.PurchaseFrame.ExitButton.MouseButton1Click:Connect(function()
- CloseEffect:Play()
- ShopBuyFrame:TweenPosition(
- UDim2.new(0.3, 0,-0.6, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.25, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.25)
- PurchaseDebounce = true
- ShopBuyFrame.Visible = false
- Shop.Visible = true
- PurchaseCleanup:Disconnect()
- BuyButtonInfo:Disconnect() -- << -- stuff that overlapped this was the solution
- end)
- ShopOpenFunction = ShopButton.MouseButton1Click:Connect(function()
- if Shop.Visible and PurchaseDebounce then
- ShopOpenSoundEffect:Play()
- --[[Shop:TweenPosition(
- UDim2.new(0.249, 0,-0.6, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 1, -- Time in seconds
- false -- Override any other tweens
- ) --]]
- for i,buttons in pairs(Shop.ScrollingFrame.Frame:GetChildren())do
- if buttons:IsA("ImageButton") then
- buttons.Visible = false
- buttons.Size = UDim2.new(0,0,0,0)
- end
- end
- debounce = false
- ShopTween2:Play()
- ShopTween2.Completed:Connect(function()
- Shop.Visible = false
- end)
- -- Shop.Visible = false
- elseif not Shop.Visible and PurchaseDebounce then--and not ShopBuyFrame.Position == UDim2.new(0.3, 0,0.26, 0)
- Shop.Visible = true
- ShopTween1:Play()
- ShopOpenSoundEffect:Play()
- --[[ Shop:TweenPosition(
- UDim2.new(0.249, 0,0.26, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 1, -- Time in seconds
- false -- Override any other tweens
- --nil
- )--]]
- for i,buttons in pairs(Shop.ScrollingFrame.Frame:GetChildren())do
- if buttons:IsA("ImageButton") then
- buttons.Size = UDim2.new(0,0,0,0)
- buttons.Visible = true
- end
- end
- Test = ShopTween1.Completed:Connect(function()
- -- print("completed")
- if Shop.Position == UDim2.new(0.249, 0,0.26, 0) then
- -- print("shop has landed")
- Shop.ScrollingFrame.Frame.ImageButton1:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- debounce = true
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton2:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- -- print("idk")
- wait(0.05)
- if debounce then --Shop.ScrollingFrame.Frame.ImageButton2.Size == UDim2.new(0.2, 0,0.101, 0) and
- Shop.ScrollingFrame.Frame.ImageButton3:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- -- print("button2 scalled")
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton4:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton5:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton6:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton7:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton8:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton9:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton10:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton11:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton12:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton13:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton14:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton15:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- wait(0.05)
- if debounce then
- Shop.ScrollingFrame.Frame.ImageButton16:TweenSize(
- UDim2.new(0.2, 0,0.101, 0),
- "Out", -- Easing Direction
- "Quad", -- Easing Style
- 0.05, -- Time in seconds
- false -- Override any other tweens
- )
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- Test:Disconnect() -- Disconnecting when the shop gets closet just in case and performance!!
- --ShopOpenFunction:Disconnect()
- end)
- end
- end)
- -- Server Script
- local SwordBuy = game:GetService("ReplicatedStorage").ImportantEvents.SwordBuy
- SwordBuy.OnServerEvent:Connect(function(Player,Price,Name)
- print("Price is " .. Price .. " and name " ,Name)
- print(Price)
- print(Name)
- if Player.SwordValues:FindFirstChild(Name).Value == false then
- print("Sword Not Owned " .. Name)
- if Player.leaderstats["Coins 💰"].Value >= Price then
- print("Purchasing New Sword" .. Name)
- Player.leaderstats["Coins 💰"].Value = Player.leaderstats["Coins 💰"].Value - Price
- Player.SwordValues:FindFirstChild(Name).Value = true
- -- Auto Equipping the Sword
- local Song = "COINS!!!"
- -- firing back
- SwordBuy:FireClient(Player,Name,Song)
- for i, tools in pairs(game.ReplicatedStorage.SwordsFolder:GetChildren()) do
- if tools:IsA("Tool") then --and tools.Name == Name
- -- print("works")
- -- print(tools)
- if Player.Backpack:FindFirstChild(tools.Name) then
- if game.ServerStorage:FindFirstChild(Player.Name .. " Storage") then
- print("Found Another Folder")
- game.ServerStorage:FindFirstChild(Player.Name .. " Storage"):Destroy()
- local PlayersStorageFolder = Instance.new("Folder",game.ServerStorage)
- PlayersStorageFolder.Name = Player.Name .. " Storage"
- local previoussword = Player.Backpack:FindFirstChild(tools.Name)
- local previousItemsFolder = Instance.new("Folder",PlayersStorageFolder)
- previousItemsFolder.Name = "previousItemsFolder"
- previoussword.Parent = previousItemsFolder
- local NewSword = game.ReplicatedStorage.SwordsFolder:FindFirstChild(Name):Clone()
- NewSword.Parent = Player.Backpack
- else
- print("Tool Found ".. tostring(Player.Backpack:FindFirstChild(tools.Name)))
- local PlayersStorageFolder = Instance.new("Folder",game.ServerStorage)
- PlayersStorageFolder.Name = Player.Name .. " Storage"
- local previoussword = Player.Backpack:FindFirstChild(tools.Name)
- local previousItemsFolder = Instance.new("Folder",PlayersStorageFolder)
- previousItemsFolder.Name = "previousItemsFolder"
- previoussword.Parent = previousItemsFolder
- local NewSword = game.ReplicatedStorage.SwordsFolder:FindFirstChild(Name):Clone()
- NewSword.Parent = Player.Backpack
- end
- end
- end
- end
- else
- warn("lier") -- player is most likely hacking
- end
- else
- -- Need to check if player has sword in inventory or not!!
- print("Sword Owned Equipping " .. Name)
- local Song = "Knife Equip"
- -- firing back
- SwordBuy:FireClient(Player,Name,Song)
- for i,Swords in pairs(game.ReplicatedStorage.SwordsFolder:GetChildren()) do
- if Player.Backpack:FindFirstChild(Name) then
- -- Player.Backpack:FindFirstChild(Name):Destroy()
- print(Name .. " found")
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement