Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local RepllicatedStorage = game:GetService("ReplicatedStorage")
- local DSS = game:GetService("DataStoreService"):GetDataStore("SxScripting")
- game.Players.PlayerAdded:Connect(function(Player)
- -- Varaibles --
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
- -- BASICS --
- local statFolder = Instance.new("Folder", Player)
- statFolder.Name = "statFolder";
- local currentEXP = Instance.new("IntValue", statFolder)
- currentEXP.Name = "currentExp";
- local maxEXP = Instance.new("IntValue", statFolder);
- maxEXP.Name = "maxEXP"
- maxEXP.Value = 100;
- local Level = Instance.new("IntValue", statFolder)
- Level.Name = "Level";
- Level.Value = 1;
- local Presitge = Instance.new("IntValue", statFolder)
- Presitge.Name = "Prestige"
- Presitge.Value = 0;
- -- EXTRA --
- local StatPoints = Instance.new("IntValue",statFolder)
- StatPoints.Name = "StatPoints";
- StatPoints.Value = 10;
- local newSpeed = Instance.new("IntValue", statFolder)
- newSpeed.Name = "Speed";
- newSpeed.Value = 16;
- local newHealth = Instance.new("IntValue",statFolder)
- newHealth.Name = "Health";
- newHealth.Value = 100;
- local newPower = Instance.new("IntValue", statFolder)
- newPower.Name = "Power";
- newPower.Value = 0;
- local Success, Value = pcall(function()
- return DSS:GetAsync(Player.UserId)
- end)
- if Success then
- warn("YES")
- if Value then
- warn(Value)
- for i,v in pairs(Value) do
- local currentValues = statFolder:FindFirstChild(i)
- if not currentValues then continue end
- currentValues.Value = v
- end
- else
- warn("NO")
- end
- else
- warn("NO")
- end
- currentEXP.Changed:Connect(function()
- if currentEXP.Value >= maxEXP.Value then
- local Remaining = currentEXP.Value - maxEXP.Value;
- currentEXP.Value = Remaining;
- Level.Value += 1;
- StatPoints.Value += 1;
- maxEXP.Value += math.random(50,100);
- end
- end)
- RunService.Heartbeat:Connect(function()
- Humanoid.MaxHealth = newHealth.Value;
- Humanoid.WalkSpeed = newSpeed.Value;
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(Player: Player)
- local TableOfValues = {}
- for Index,Value in pairs(Player:WaitForChild("statFolder"):GetChildren()) do
- TableOfValues[Value.Name] = Value.Value
- end
- local Success, Error = pcall(function()
- DSS:SetAsync(Player.UserId, TableOfValues)
- end)
- if Error then
- warn(Error)
- end
- end)
- game:BindToClose(function()
- for i,player in pairs(game.Players:GetPlayers()) do
- local TableOfValues = {}
- for Index,Value in pairs(player:WaitForChild("statFolder"):GetChildren()) do
- TableOfValues[Value.Name] = Value.Value;
- end
- local Success, Error = pcall(function()
- DSS:SetAsync(player.UserId, TableOfValues)
- end)
- if Error then
- warn(Error)
- end
- end
- end)
- RepllicatedStorage.Events.statChecker.OnServerInvoke = function(Player: Player, statTitle: TextLabel, AddPoints)
- local statFolder = Player:WaitForChild("statFolder")
- local StatPoints = statFolder.StatPoints;
- if StatPoints.Value >= 1 then
- StatPoints.Value -= 1;
- statFolder[statTitle.Name].Value += 1;
- return true
- end
- return false;
- end
- local Debounce: {} = {}
- local Combo = {};
- RepllicatedStorage.Events.Punches.OnServerEvent:Connect(function(Player)
- if Debounce[Player] then return end
- Debounce[Player] = true
- if not Combo[Player] then Combo[Player] = 0; end
- Combo[Player] += 1;
- local Animations = {
- RepllicatedStorage.Animations.M1;
- RepllicatedStorage.Animations.M2;
- RepllicatedStorage.Animations.M3;
- RepllicatedStorage.Animations.M4;
- RepllicatedStorage.Animations.M5;
- }
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- Humanoid:LoadAnimation(Animations[Combo[Player]]):Play();
- Player:WaitForChild("statFolder").currentExp.Value += 10;
- if Combo[Player] == #Animations then
- Combo[Player] = 0;
- end
- task.wait(.4)
- Debounce[Player] = nil;
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement