killerbrenden

Custom Stat Creator

Mar 9th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.13 KB | None | 0 0
  1. local toolbar = plugin:CreateToolbar("Stat Creator")
  2.  
  3. local button = toolbar:CreateButton(
  4.     "Create Custom Stat",
  5.     "Create A New Custom Stat Script",
  6.     ""
  7. )
  8.  
  9. button.Click:Connect(function()
  10.     if game:GetService("CoreGui"):FindFirstChild("StatGui") then
  11.         game:GetService("CoreGui"):FindFirstChild("StatGui"):Destroy()
  12.     else
  13.         local statGui = Instance.new("ScreenGui",game:GetService("CoreGui"))
  14.         statGui.Name = "StatGui"
  15.        
  16.         local values = {"BoolValue","IntValue","NumberValue","StringValue"}
  17.        
  18.         --// Visuals
  19.         local imageHolder = Instance.new("ImageLabel",statGui)
  20.         imageHolder.Name = "MainFrame"
  21.         imageHolder.Size = UDim2.new(0.5,0,0.5,0)
  22.         imageHolder.AnchorPoint = Vector2.new(0.5,0.5)
  23.         imageHolder.BackgroundTransparency = 1
  24.         imageHolder.Position = UDim2.new(0.5,0,0.5,0)
  25.         imageHolder.Image = "rbxassetid://3570695787"
  26.         imageHolder.ImageTransparency = 0.5
  27.         imageHolder.ImageColor3 = Color3.fromRGB(10,10,10)
  28.         imageHolder.ScaleType = Enum.ScaleType.Slice
  29.         imageHolder.SliceCenter = Rect.new(100,100,100,100)
  30.         imageHolder.SliceScale = 0.12
  31.        
  32.         local textLabel = Instance.new("TextLabel",imageHolder)
  33.         textLabel.Name = "Title"
  34.         textLabel.BackgroundTransparency = 1
  35.         textLabel.Size = UDim2.new(1,0,0.15,0)
  36.         textLabel.TextScaled = true
  37.         textLabel.TextWrapped = true
  38.         textLabel.TextColor3 = Color3.fromRGB(225,225,225)
  39.         textLabel.Font = Enum.Font.SourceSansLight
  40.         textLabel.Text = "Custom Stat Creator"
  41.        
  42.         local scrollingFrame = Instance.new("ScrollingFrame",imageHolder)
  43.         scrollingFrame.Position = UDim2.new(0,0,0.25,0)
  44.         scrollingFrame.Size = UDim2.new(1,0,0.75,0)
  45.         scrollingFrame.BackgroundTransparency = 1
  46.         scrollingFrame.ScrollBarThickness = 10
  47.        
  48.         local layout = Instance.new("UIListLayout",scrollingFrame)
  49.         layout.Padding = UDim.new(0,5)
  50.         layout.Name = "Layout"
  51.        
  52.         for _,value in pairs (values) do
  53.             local textButton = Instance.new("TextButton",scrollingFrame)
  54.             textButton.Name = value
  55.             textButton.Text = value
  56.             textButton.Size = UDim2.new(1,0,0.075,0)
  57.             textButton.BackgroundTransparency = 0.75
  58.             textButton.BorderSizePixel = 0
  59.             textButton.TextScaled = true
  60.             textButton.TextWrapped = true
  61.             textButton.Font = Enum.Font.SourceSansLight
  62.             textButton.TextColor3 = Color3.fromRGB(255,255,255)
  63.            
  64.             if textButton.Name == "IntValue" then
  65.                 textButton.MouseButton1Click:Connect(function()
  66.                     scrollingFrame.Visible = false
  67.                     local textBox1 = Instance.new("TextBox",imageHolder)
  68.                     textBox1.Name = "StatName"
  69.                     textBox1.Size = UDim2.new(1,0,0.1,0)
  70.                     textBox1.Position = UDim2.new(0,0,0.3,0)
  71.                     textBox1.AnchorPoint = Vector2.new(0,0.3)
  72.                     textBox1.BackgroundTransparency = 1
  73.                     textBox1.Font = Enum.Font.SourceSansLight
  74.                     textBox1.Text = ""
  75.                     textBox1.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  76.                     textBox1.TextColor3 = Color3.fromRGB(255,255,255)
  77.                     textBox1.PlaceholderText = "Enter Stat Name (Ex: Money)"
  78.                     textBox1.TextScaled = true
  79.                     textBox1.TextWrapped = true
  80.                    
  81.                     local textBox2 = Instance.new("TextBox",imageHolder)
  82.                     textBox2.Name = "DefaultValue"
  83.                     textBox2.Size = UDim2.new(1,0,0.1,0)
  84.                     textBox2.Position = UDim2.new(0,0,0.6,0)
  85.                     textBox2.AnchorPoint = Vector2.new(0,0.6)
  86.                     textBox2.BackgroundTransparency = 1
  87.                     textBox2.Font = Enum.Font.SourceSansLight
  88.                     textBox2.Text = ""
  89.                     textBox2.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  90.                     textBox2.TextColor3 = Color3.fromRGB(255,255,255)
  91.                     textBox2.PlaceholderText = "Enter Default Value (Ex: 50)"
  92.                     textBox2.TextScaled = true
  93.                     textBox2.TextWrapped = true
  94.                    
  95.                     local textButton2 = Instance.new("TextButton",imageHolder)
  96.                     textButton2.Name = "CreateButton"
  97.                     textButton2.Text = "Create"
  98.                     textButton2.Size = UDim2.new(1,0,0.15,0)
  99.                     textButton2.BackgroundTransparency = 1
  100.                     textButton2.BorderSizePixel = 0
  101.                     textButton2.TextScaled = true
  102.                     textButton2.TextWrapped = true
  103.                     textButton2.Font = Enum.Font.SourceSansLight
  104.                     textButton2.TextColor3 = Color3.fromRGB(255,255,255)
  105.                     textButton2.Position = UDim2.new(0,0,0.9,0)
  106.                     textButton2.AnchorPoint = Vector2.new(0,0.9)
  107.                    
  108.                     textButton2.MouseButton1Click:Connect(function()
  109.                         if textBox1.Text ~= "" then
  110.                             if textBox2.Text ~= "" then
  111.                                 if game:GetService("ServerStorage"):FindFirstChild("SaveInStudio") then
  112.                                    
  113.                                 else
  114.                                     local sin = Instance.new("BoolValue",game:GetService("ServerStorage"))
  115.                                     sin.Name = "SaveInStudio"
  116.                                     sin.Value = true
  117.                                 end
  118.                                 local statName = textBox1.Text
  119.                                 local defaultValue = textBox2.Text
  120.                                                                
  121.                                 local serverScript = Instance.new("Script",game:GetService("ServerScriptService"))
  122.                                 serverScript.Name = "Module Handler"
  123.                                
  124.                                 local moduleScript = Instance.new("ModuleScript",serverScript)
  125.                                 moduleScript.Name = "Data Handler"
  126.                                
  127. serverScript.Source = [[
  128. --// killerbrenden 3/5/2020
  129.  
  130. local dataHandler = require(script["Data Handler"])
  131.  
  132. game.Players.PlayerAdded:Connect(function(player)
  133.     dataHandler:LoadData(player)
  134. end)
  135. ]]
  136.  
  137. moduleScript.Source = [[
  138. --// killerbrenden 3/5/2020
  139.  
  140. local dataModule = {}
  141.  
  142. local DataStore2 = require(1936396537)
  143.  
  144. local defaultValue = ]]..defaultValue..[[
  145.  
  146. DataStore2.Combine("_game_data_","]]..statName..[[")
  147.  
  148. function dataModule:LoadData(player)
  149.     local leaderstats = Instance.new("Folder",player)
  150.     leaderstats.Name = "leaderstats"
  151.    
  152.     local ]]..statName..[[ = Instance.new("IntValue",leaderstats)
  153.     ]]..statName..[[.Name = "]]..statName..[["
  154.    
  155.     local ]]..statName..[[Store = DataStore2("]]..statName..[[",player)
  156.    
  157.     local function update]]..statName..[[(value)
  158.         player:WaitForChild("leaderstats"):FindFirstChild("]]..statName..[[").Value = value
  159.     end
  160.    
  161.     update]]..statName..[[(]]..statName..[[Store:Get(defaultValue))
  162.    
  163.     ]]..statName..[[Store:OnUpdate(update]]..statName..[[)
  164. end
  165.  
  166. return dataModule
  167. ]]
  168. wait(0.25)
  169. statGui:Destroy()
  170.                             end
  171.                         end
  172.                     end)
  173.                 end)
  174.             elseif textButton.Name == "NumberValue" then
  175.                 textButton.MouseButton1Click:Connect(function()
  176.                     scrollingFrame.Visible = false
  177.                     local textBox1 = Instance.new("TextBox",imageHolder)
  178.                     textBox1.Name = "StatName"
  179.                     textBox1.Size = UDim2.new(1,0,0.1,0)
  180.                     textBox1.Position = UDim2.new(0,0,0.3,0)
  181.                     textBox1.AnchorPoint = Vector2.new(0,0.3)
  182.                     textBox1.BackgroundTransparency = 1
  183.                     textBox1.Font = Enum.Font.SourceSansLight
  184.                     textBox1.Text = ""
  185.                     textBox1.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  186.                     textBox1.TextColor3 = Color3.fromRGB(255,255,255)
  187.                     textBox1.PlaceholderText = "Enter Stat Name (Ex: Coins)"
  188.                     textBox1.TextScaled = true
  189.                     textBox1.TextWrapped = true
  190.                    
  191.                     local textBox2 = Instance.new("TextBox",imageHolder)
  192.                     textBox2.Name = "DefaultValue"
  193.                     textBox2.Size = UDim2.new(1,0,0.1,0)
  194.                     textBox2.Position = UDim2.new(0,0,0.6,0)
  195.                     textBox2.AnchorPoint = Vector2.new(0,0.6)
  196.                     textBox2.BackgroundTransparency = 1
  197.                     textBox2.Font = Enum.Font.SourceSansLight
  198.                     textBox2.Text = ""
  199.                     textBox2.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  200.                     textBox2.TextColor3 = Color3.fromRGB(255,255,255)
  201.                     textBox2.PlaceholderText = "Enter Default Value (Ex: 25)"
  202.                     textBox2.TextScaled = true
  203.                     textBox2.TextWrapped = true
  204.                    
  205.                     local textButton2 = Instance.new("TextButton",imageHolder)
  206.                     textButton2.Name = "CreateButton"
  207.                     textButton2.Text = "Create"
  208.                     textButton2.Size = UDim2.new(1,0,0.15,0)
  209.                     textButton2.BackgroundTransparency = 1
  210.                     textButton2.BorderSizePixel = 0
  211.                     textButton2.TextScaled = true
  212.                     textButton2.TextWrapped = true
  213.                     textButton2.Font = Enum.Font.SourceSansLight
  214.                     textButton2.TextColor3 = Color3.fromRGB(255,255,255)
  215.                     textButton2.Position = UDim2.new(0,0,0.9,0)
  216.                     textButton2.AnchorPoint = Vector2.new(0,0.9)
  217.                    
  218.                     textButton2.MouseButton1Click:Connect(function()
  219.                         if textBox1.Text ~= "" then
  220.                             if textBox2.Text ~= "" then
  221.                                 if game:GetService("ServerStorage"):FindFirstChild("SaveInStudio") then
  222.                                    
  223.                                 else
  224.                                     local sin = Instance.new("BoolValue",game:GetService("ServerStorage"))
  225.                                     sin.Name = "SaveInStudio"
  226.                                     sin.Value = true
  227.                                 end
  228.                                
  229.                                 local statName = textBox1.Text
  230.                                 local defaultValue = textBox2.Text
  231.                                                                
  232.                                 local serverScript = Instance.new("Script",game:GetService("ServerScriptService"))
  233.                                 serverScript.Name = "Module Handler"
  234.                                
  235.                                 local moduleScript = Instance.new("ModuleScript",serverScript)
  236.                                 moduleScript.Name = "Data Handler"
  237.                                
  238. serverScript.Source = [[
  239. --// killerbrenden 3/5/2020
  240.  
  241. local dataHandler = require(script["Data Handler"])
  242.  
  243. game.Players.PlayerAdded:Connect(function(player)
  244.     dataHandler:LoadData(player)
  245. end)
  246. ]]
  247.  
  248. moduleScript.Source = [[
  249. --// killerbrenden 3/5/2020
  250.  
  251. local dataModule = {}
  252.  
  253. local DataStore2 = require(1936396537)
  254.  
  255. local defaultValue = ]]..defaultValue..[[
  256.  
  257. DataStore2.Combine("_game_data_","]]..statName..[[")
  258.  
  259. function dataModule:LoadData(player)
  260.     local leaderstats = Instance.new("Folder",player)
  261.     leaderstats.Name = "leaderstats"
  262.    
  263.     local ]]..statName..[[ = Instance.new("NumberValue",leaderstats)
  264.     ]]..statName..[[.Name = "]]..statName..[["
  265.    
  266.     local ]]..statName..[[Store = DataStore2("]]..statName..[[",player)
  267.    
  268.     local function update]]..statName..[[(value)
  269.         player:WaitForChild("leaderstats"):FindFirstChild("]]..statName..[[").Value = value
  270.     end
  271.    
  272.     update]]..statName..[[(]]..statName..[[Store:Get(defaultValue))
  273.    
  274.     ]]..statName..[[Store:OnUpdate(update]]..statName..[[)
  275. end
  276.  
  277. return dataModule
  278. ]]
  279. wait(0.25)
  280. statGui:Destroy()
  281.                             end
  282.                         end
  283.                     end)
  284.                 end)
  285.             elseif textButton.Name == "StringValue" then
  286.                 textButton.MouseButton1Click:Connect(function()
  287.                     scrollingFrame.Visible = false
  288.                     local textBox1 = Instance.new("TextBox",imageHolder)
  289.                     textBox1.Name = "StatName"
  290.                     textBox1.Size = UDim2.new(1,0,0.1,0)
  291.                     textBox1.Position = UDim2.new(0,0,0.3,0)
  292.                     textBox1.AnchorPoint = Vector2.new(0,0.3)
  293.                     textBox1.BackgroundTransparency = 1
  294.                     textBox1.Font = Enum.Font.SourceSansLight
  295.                     textBox1.Text = ""
  296.                     textBox1.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  297.                     textBox1.TextColor3 = Color3.fromRGB(255,255,255)
  298.                     textBox1.PlaceholderText = "Enter Stat Name (Ex: Spell)"
  299.                     textBox1.TextScaled = true
  300.                     textBox1.TextWrapped = true
  301.                    
  302.                     local textBox2 = Instance.new("TextBox",imageHolder)
  303.                     textBox2.Name = "DefaultValue"
  304.                     textBox2.Size = UDim2.new(1,0,0.1,0)
  305.                     textBox2.Position = UDim2.new(0,0,0.6,0)
  306.                     textBox2.AnchorPoint = Vector2.new(0,0.6)
  307.                     textBox2.BackgroundTransparency = 1
  308.                     textBox2.Font = Enum.Font.SourceSansLight
  309.                     textBox2.Text = ""
  310.                     textBox2.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  311.                     textBox2.TextColor3 = Color3.fromRGB(255,255,255)
  312.                     textBox2.PlaceholderText = "Enter Default Value (Ex: None)"
  313.                     textBox2.TextScaled = true
  314.                     textBox2.TextWrapped = true
  315.                    
  316.                     local textButton2 = Instance.new("TextButton",imageHolder)
  317.                     textButton2.Name = "CreateButton"
  318.                     textButton2.Text = "Create"
  319.                     textButton2.Size = UDim2.new(1,0,0.15,0)
  320.                     textButton2.BackgroundTransparency = 1
  321.                     textButton2.BorderSizePixel = 0
  322.                     textButton2.TextScaled = true
  323.                     textButton2.TextWrapped = true
  324.                     textButton2.Font = Enum.Font.SourceSansLight
  325.                     textButton2.TextColor3 = Color3.fromRGB(255,255,255)
  326.                     textButton2.Position = UDim2.new(0,0,0.9,0)
  327.                     textButton2.AnchorPoint = Vector2.new(0,0.9)
  328.                    
  329.                     textButton2.MouseButton1Click:Connect(function()
  330.                         if textBox1.Text ~= "" then
  331.                             if textBox2.Text ~= "" then
  332.                                 if game:GetService("ServerStorage"):FindFirstChild("SaveInStudio") then
  333.                                    
  334.                                 else
  335.                                     local sin = Instance.new("BoolValue",game:GetService("ServerStorage"))
  336.                                     sin.Name = "SaveInStudio"
  337.                                     sin.Value = true
  338.                                 end
  339.                                
  340.                                 local statName = textBox1.Text
  341.                                 local defaultValue = textBox2.Text
  342.                                                                
  343.                                 local serverScript = Instance.new("Script",game:GetService("ServerScriptService"))
  344.                                 serverScript.Name = "Module Handler"
  345.                                
  346.                                 local moduleScript = Instance.new("ModuleScript",serverScript)
  347.                                 moduleScript.Name = "Data Handler"
  348.                                
  349. serverScript.Source = [[
  350. --// killerbrenden 3/5/2020
  351.  
  352. local dataHandler = require(script["Data Handler"])
  353.  
  354. game.Players.PlayerAdded:Connect(function(player)
  355.     dataHandler:LoadData(player)
  356. end)
  357. ]]
  358.  
  359. moduleScript.Source = [[
  360. --// killerbrenden 3/5/2020
  361.  
  362. local dataModule = {}
  363.  
  364. local DataStore2 = require(1936396537)
  365.  
  366. local defaultValue = "]]..defaultValue..[["
  367.  
  368. DataStore2.Combine("_game_data_","]]..statName..[[")
  369.  
  370. function dataModule:LoadData(player)
  371.     local leaderstats = Instance.new("Folder",player)
  372.     leaderstats.Name = "leaderstats"
  373.    
  374.     local ]]..statName..[[ = Instance.new("StringValue",leaderstats)
  375.     ]]..statName..[[.Name = "]]..statName..[["
  376.    
  377.     local ]]..statName..[[Store = DataStore2("]]..statName..[[",player)
  378.    
  379.     local function update]]..statName..[[(value)
  380.         player:WaitForChild("leaderstats"):FindFirstChild("]]..statName..[[").Value = value
  381.     end
  382.    
  383.     update]]..statName..[[(]]..statName..[[Store:Get(defaultValue))
  384.    
  385.     ]]..statName..[[Store:OnUpdate(update]]..statName..[[)
  386. end
  387.  
  388. return dataModule
  389. ]]
  390. wait(0.25)
  391. statGui:Destroy()
  392.                             end
  393.                         end
  394.                     end)
  395.                 end)
  396.             elseif textButton.Name == "BoolValue" then
  397.                 textButton.MouseButton1Click:Connect(function()
  398.                     scrollingFrame.Visible = false
  399.                     local textBox1 = Instance.new("TextBox",imageHolder)
  400.                     textBox1.Name = "StatName"
  401.                     textBox1.Size = UDim2.new(1,0,0.1,0)
  402.                     textBox1.Position = UDim2.new(0,0,0.3,0)
  403.                     textBox1.AnchorPoint = Vector2.new(0,0.3)
  404.                     textBox1.BackgroundTransparency = 1
  405.                     textBox1.Font = Enum.Font.SourceSansLight
  406.                     textBox1.Text = ""
  407.                     textBox1.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  408.                     textBox1.TextColor3 = Color3.fromRGB(255,255,255)
  409.                     textBox1.PlaceholderText = "Enter Stat Name (Ex: HasCar)"
  410.                     textBox1.TextScaled = true
  411.                     textBox1.TextWrapped = true
  412.                    
  413.                     local textBox2 = Instance.new("TextBox",imageHolder)
  414.                     textBox2.Name = "DefaultValue"
  415.                     textBox2.Size = UDim2.new(1,0,0.1,0)
  416.                     textBox2.Position = UDim2.new(0,0,0.6,0)
  417.                     textBox2.AnchorPoint = Vector2.new(0,0.6)
  418.                     textBox2.BackgroundTransparency = 1
  419.                     textBox2.Font = Enum.Font.SourceSansLight
  420.                     textBox2.Text = ""
  421.                     textBox2.PlaceholderColor3 = Color3.fromRGB(255,255,255)
  422.                     textBox2.TextColor3 = Color3.fromRGB(255,255,255)
  423.                     textBox2.PlaceholderText = "Enter Default Value (Ex: false)"
  424.                     textBox2.TextScaled = true
  425.                     textBox2.TextWrapped = true
  426.                    
  427.                     local textButton2 = Instance.new("TextButton",imageHolder)
  428.                     textButton2.Name = "CreateButton"
  429.                     textButton2.Text = "Create"
  430.                     textButton2.Size = UDim2.new(1,0,0.15,0)
  431.                     textButton2.BackgroundTransparency = 1
  432.                     textButton2.BorderSizePixel = 0
  433.                     textButton2.TextScaled = true
  434.                     textButton2.TextWrapped = true
  435.                     textButton2.Font = Enum.Font.SourceSansLight
  436.                     textButton2.TextColor3 = Color3.fromRGB(255,255,255)
  437.                     textButton2.Position = UDim2.new(0,0,0.9,0)
  438.                     textButton2.AnchorPoint = Vector2.new(0,0.9)
  439.                    
  440.                     textButton2.MouseButton1Click:Connect(function()
  441.                         if textBox1.Text ~= "" then
  442.                             if textBox2.Text ~= "" then
  443.                                 if game:GetService("ServerStorage"):FindFirstChild("SaveInStudio") then
  444.                                    
  445.                                 else
  446.                                     local sin = Instance.new("BoolValue",game:GetService("ServerStorage"))
  447.                                     sin.Name = "SaveInStudio"
  448.                                     sin.Value = true
  449.                                 end
  450.                                
  451.                                 local statName = textBox1.Text
  452.                                 local defaultValue = string.lower(textBox2.Text)
  453.                                                                
  454.                                 local serverScript = Instance.new("Script",game:GetService("ServerScriptService"))
  455.                                 serverScript.Name = "Module Handler"
  456.                                
  457.                                 local moduleScript = Instance.new("ModuleScript",serverScript)
  458.                                 moduleScript.Name = "Data Handler"
  459.                                
  460. serverScript.Source = [[
  461. --// killerbrenden 3/5/2020
  462.  
  463. local dataHandler = require(script["Data Handler"])
  464.  
  465. game.Players.PlayerAdded:Connect(function(player)
  466.     dataHandler:LoadData(player)
  467. end)
  468. ]]
  469.  
  470. moduleScript.Source = [[
  471. --// killerbrenden 3/5/2020
  472.  
  473. local dataModule = {}
  474.  
  475. local DataStore2 = require(1936396537)
  476.  
  477. local defaultValue = ]]..defaultValue..[[
  478.  
  479. DataStore2.Combine("_game_data_","]]..statName..[[")
  480.  
  481. function dataModule:LoadData(player)
  482.     local leaderstats = Instance.new("Folder",player)
  483.     leaderstats.Name = "leaderstats"
  484.    
  485.     local ]]..statName..[[ = Instance.new("BoolValue",leaderstats)
  486.     ]]..statName..[[.Name = "]]..statName..[["
  487.    
  488.     local ]]..statName..[[Store = DataStore2("]]..statName..[[",player)
  489.    
  490.     local function update]]..statName..[[(value)
  491.         player:WaitForChild("leaderstats"):FindFirstChild("]]..statName..[[").Value = value
  492.     end
  493.    
  494.     update]]..statName..[[(]]..statName..[[Store:Get(defaultValue))
  495.    
  496.     ]]..statName..[[Store:OnUpdate(update]]..statName..[[)
  497. end
  498.  
  499. return dataModule
  500. ]]
  501. wait(0.25)
  502. statGui:Destroy()
  503.                             end
  504.                         end
  505.                     end)
  506.                 end)
  507.             end
  508.         end
  509.     end
  510. end)
Advertisement
Add Comment
Please, Sign In to add comment