Advertisement
Guest User

Local Script

a guest
Oct 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. --Confirmation Dialog OnClick
  2. local itemModule = require(game.ReplicatedStorage.Modules.ItemsModule)
  3. local button = script.Parent
  4. local active = false
  5.  
  6. local function SetCraftButton(playerData, itemName)
  7.     local craftingModule = require(game.ReplicatedStorage.Modules.CraftingModule)  
  8.  
  9.     local craftButton = button.Parent.Parent.CraftingFrame.Craft
  10.     local canCraft = button.Parent.Parent.CraftingFrame.CanCraft
  11.     local dialogSettings = require(game.StarterGui.DialogSettingsModule)
  12.    
  13.     local craftingItem = itemModule:GetItemByName(itemName)
  14.    
  15.     if craftingModule.CanCraftItem(playerData, craftingItem) then
  16.         canCraft.Value = true
  17.         craftButton.BackgroundColor3 = dialogSettings.GreenButtonColor3
  18.     else
  19.         canCraft.Value = false
  20.         craftButton.BackgroundColor3 = dialogSettings.GrayButtonColor3
  21.     end    
  22. end
  23.  
  24. local function OnYesClick()
  25.     local canCraftValue = button.Parent.Parent.CraftingFrame.CanCraft.Value
  26.    
  27.     if active == false and canCraftValue then
  28.         active = true
  29.        
  30.         local selected = button.Parent.Parent.CraftingFrame.SelectedName
  31.                
  32.         local craftItemFunction = game.ReplicatedStorage.Crafting.CraftItemFunction
  33.         local response = craftItemFunction:InvokeServer(selected.Value)
  34.        
  35.         local player = game.Players.LocalPlayer
  36.         local playerDataFromServer = game.ReplicatedStorage.PlayerData.PlayerDataFromServerFunction
  37.         local playerData = playerDataFromServer:InvokeServer()
  38.         _G.PlayerData[player.UserId] = playerData
  39.        
  40.         local optionsDialogFrame = button.Parent
  41.         optionsDialogFrame.Visible = false
  42.        
  43.         --SetCraftButton(playerData,selected.Value)
  44.        
  45.         local confirmationFrame = button.Parent.Parent.ConfirmationFrame
  46.         confirmationFrame.Content.Text = response      
  47.         confirmationFrame.Visible = true
  48.        
  49.         active = false
  50.     end
  51.    
  52. end
  53.  
  54. button.MouseButton1Click:Connect(OnYesClick)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement