Advertisement
SxScripting

Level System [Local]

Feb 27th, 2023
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local TweenService = game:GetService("TweenService")
  3.  
  4. local Player = game.Players.LocalPlayer
  5. local PlayerGui = Player:WaitForChild("PlayerGui")
  6. local Character = Player.Character or Player.CharacterAdded:Wait()
  7. local Humanoid = Character:WaitForChild("Humanoid");
  8.  
  9. local MainFrame = PlayerGui.StatGUI.MainFrame
  10. local statFolder = Player:WaitForChild("statFolder")
  11.  
  12. local WhiteList = {
  13. "Power";
  14. "Health";
  15. "Speed";
  16. "StatPoints"
  17. }
  18.  
  19. local function detectChange(Value: IntValue)
  20. MainFrame[Value.Name].Text = Value.Name..": "..Value.Value;
  21. end
  22.  
  23. PlayerGui.StatGUI.MenuButton.TextButton.MouseButton1Click:Connect(function()
  24. MainFrame.Visible = not MainFrame.Visible;
  25. end)
  26.  
  27. for i,v in pairs(statFolder:GetChildren()) do
  28. if not table.find(WhiteList, v.Name) then continue end
  29. v.Changed:Connect(function()
  30. if not table.find(WhiteList, v.Name) then return end
  31. detectChange(v)
  32. end)
  33. detectChange(v)
  34. end
  35.  
  36. for _,v: ImageButton in pairs(MainFrame:GetDescendants()) do
  37. if not v:IsA("ImageButton") then continue end
  38. v.MouseButton1Click:Connect(function()
  39. if not ReplicatedStorage.Events.statChecker:InvokeServer(v.Parent, false) then return end
  40. end)
  41. end
  42.  
  43. -- EXPERIENCE CHANGE --
  44. local EXPFrame = PlayerGui.StatGUI.ExpFrame;
  45. local currentEXP = statFolder.currentExp;
  46. local MaxEXP = statFolder.maxEXP;
  47. local Level = statFolder.Level;
  48.  
  49. Level.Changed:Connect(function()
  50. EXPFrame[Level.Name].Text = "Level: "..Level.Value;
  51. local LevelEffect = ReplicatedStorage.Effects.ExpPart.LevelUp:Clone();
  52. LevelEffect.Parent = Player.Character:WaitForChild("HumanoidRootPart")
  53. LevelEffect:Emit(450)
  54. game.Debris:AddItem(LevelEffect, .5);
  55. end)
  56. EXPFrame[Level.Name].Text = "Level: "..Level.Value;
  57.  
  58. statFolder.currentExp.Changed:Connect(function()
  59. EXPFrame.EXPtext.Text = currentEXP.Value.." / "..MaxEXP.Value;
  60. TweenService:Create(EXPFrame.Frame, TweenInfo.new(.5), {Size = UDim2.new((currentEXP.Value + MaxEXP.Value/100)/MaxEXP.Value,0,1,0)}):Play()
  61. end)
  62. EXPFrame.EXPtext.Text = currentEXP.Value.." / "..MaxEXP.Value;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement