Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RStorage = game:GetService("ReplicatedStorage")
- local DDS = game:GetService("DataStoreService")
- local EXPSave = DDS:GetDataStore("EXPDataStoreV.1")
- local GoldSave = DDS:GetDataStore("GoldSaveStoreV.1")
- local canChangeColor = false
- local Remotes = RStorage.Remotes
- local ChangeTeamEvent = Remotes.ChangeTeam
- local UpdateShirtEvent = Remotes.UpdateShirt
- local SkinColorEvent = Remotes.UpdateSkinColor
- local UpdatePantsEvents = Remotes.UpdatePants
- local EXPEvent = Remotes.EXPEvent
- local GroupId = 3828960
- game.Players.PlayerAdded:Connect(function(plr)
- plr.CharacterAdded:Connect(function(char)
- if not plr:FindFirstChild('PlayerStats') then
- local leaderstats = Instance.new("Folder", plr)
- leaderstats.Name = "leaderstats"
- local Money = Instance.new("NumberValue", leaderstats)
- Money.Name = "Currency"
- Money.Value = 0
- local hidden = Instance.new("Folder", plr)
- hidden.Name = "PlayerStats"
- local SkinColor = Instance.new("BrickColorValue", hidden)
- SkinColor.Name = "SkinColor"
- SkinColor.Value = BrickColor.new("Wheat")
- local ShirtId = Instance.new("StringValue", hidden)
- ShirtId.Name = "ShirtId"
- ShirtId.Value = ""
- local PantsId = Instance.new("StringValue", hidden)
- PantsId.Name = "PantsId"
- PantsId.Value = ""
- local EXP = Instance.new("NumberValue", hidden)
- EXP.Name = "EXP"
- EXP.Value = 0
- local RankInGroup = Instance.new("StringValue", hidden)
- RankInGroup.Name = "RankInGroup"
- RankInGroup.Value = plr:GetRankInGroup(GroupId)
- char.Humanoid.WalkSpeed = 0
- char.Humanoid.JumpPower = 0
- local data, data2;
- local success, err = pcall(function()
- data = EXPSave:GetAsync(plr.UserId.. "-EXPSave")
- data2 = GoldSave:GetAsync(plr.UserId.. "-GoldSave")
- end)
- if success then
- EXP.Value = data
- Money.Value = data2
- else
- warn('Could not save '.. plr.Name.. "'s".. " data!".. " ERROR: ".. err)
- end
- while true do
- for i,v in pairs(game.Workspace:WaitForChild(plr.Name):GetChildren()) do
- if v:IsA("MeshPart") or v:IsA("Part") then
- v.BrickColor = plr.PlayerStats.SkinColor.Value
- elseif v:IsA("Shirt") then
- v.ShirtTemplate = plr.PlayerStats.ShirtId.Value
- elseif v:IsA("Pants") then
- v.PantsTemplate = plr.PlayerStats.PantsId.Value
- end
- end
- wait(3)
- end
- end
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- local success, err = pcall(function()
- EXPSave:SetAsync(plr.UserId.. "-EXPSave", plr.PlayerStats.EXP.Value)
- GoldSave:SetAsync(plr.UserId.. "-GoldSave", plr.leaderstats.Currency.Value)
- end)
- if success then
- warn('Success when saving '.. plr.Name.. "'s".. " data!")
- else
- warn('Could not save '.. plr.Name.. "'s".. " data!".. " ERROR: ".. err)
- end
- end)
- repeat wait(10)
- if not game.Workspace:FindFirstChild("TrashPile") then
- game.ReplicatedStorage.TrashPile:Clone().Parent = workspace
- end
- until game.Workspace:FindFirstChild("TrashPile")
- EXPEvent.OnServerEvent:Connect(function(plr, playerToGive, Amount, RewardType)
- if RewardType == "Give" then
- if playerToGive == plr.Name then return end
- local plrToGiveLeaderstats = game.Players:FindFirstChild(playerToGive)
- plrToGiveLeaderstats.PlayerStats.EXP.Value = plrToGiveLeaderstats.PlayerStats.EXP.Value + Amount
- elseif RewardType == "Remove" then
- local plrToRemoveLeaderstats = game.Players:FindFirstChild(playerToGive)
- plrToRemoveLeaderstats.PlayerStats.EXP.Value = plrToRemoveLeaderstats.PlayerStats.EXP.Value - Amount
- end
- end)
- ChangeTeamEvent.OnServerEvent:Connect(function(plr, color)
- plr.TeamColor = color
- plr:LoadCharacter()
- plr:WaitForChild('Character').Humanoid.WalkSpeed = 16
- plr:WaitForChild('Character').Humanoid.JumpPower = 40
- end)
- SkinColorEvent.OnServerEvent:Connect(function(plr, color)
- for i,v in pairs(game.Workspace:FindFirstChild(plr.Name):GetChildren()) do
- if v:IsA("MeshPart") or v:IsA("Part") then
- plr.PlayerStats.SkinColor.Value = color
- v.BrickColor = color
- end
- end
- end)
- UpdateShirtEvent.OnServerEvent:Connect(function(plr, shirtId)
- for i,v in pairs(game.Workspace:FindFirstChild(plr.Name):GetChildren()) do
- if v:IsA("Shirt") then
- plr.PlayerStats.ShirtId.Value = shirtId
- v.ShirtTemplate = shirtId
- end
- end
- end)
- UpdatePantsEvents.OnServerEvent:Connect(function(plr, pantsId)
- for i,v in pairs(game.Workspace:FindFirstChild(plr.Name):GetChildren()) do
- if v:IsA("Pants") then
- plr.PlayerStats.PantsId.Value = pantsId
- v.PantsTemplate = pantsId
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement