|
| 23 Dec 2014 02:05 PM |
What I need is a script that can fit in with the script I provide to make it so that not only statistics, but also the players gear travels with them to a new game that's linked 'universally' to the beginning game.
--Ex: I enter a game, step on a pad, get teleported, my stats and weapons travel with me--
local ShowHint = false -- dont change local Admins = {22342342} -- change to your UserID
function onXPChanged(player, Value2, Value1) if Value2.Value>=Value1.Value * 25 then -- change 9 to how much exp you want to for a person to level up Value2.Value = 0 Value1.Value = Value1.Value + 1 end end
function onLevelUp(player, XP, level) if player.Character~=nil then for i = 1,5 do player.Character.Humanoid.MaxHealth = player.leaderstats.Level.Value * 20 -- change 30 how much HP you want per level up player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth end end end
function onPlayerRespawned(player) wait(2) player.Character.Humanoid.MaxHealth = player.leaderstats.Level.Value * 20 -- change 30 how much HP you want per level up player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth end
game.Players.PlayerAdded:connect(function(player) local DataStore = game:GetService("DataStoreService"):GetDataStore(player.userId) if DataStore:GetAsync("Stats") == nil then DataStore:SetAsync("Stats", {1,0,0}) end local Stats = {1,0,0} Stats = DataStore:GetAsync("Stats") -- dont touch anything above. Below you can change to names you want for each stat. local Holder = Instance.new("IntValue") Holder.Name = "leaderstats" Holder.Parent = player local Value1 = Instance.new("IntValue") Value1.Name = "Lvl" -- change to name you want Value1.Parent = Holder local Value2 = Instance.new("IntValue") Value2.Name = "XP" -- change to name you want Value2.Parent = Holder local Value3 = Instance.new("IntValue") Value3.Name = "Gold" -- change to name you want Value3.Parent = Holder local Value4 = Instance.new("IntValue") Value4.Name = "Tokens" Value4.Parent = Holder local Value5 = Instance.new("IntValue") Value5.Name = "Gems" Value5.Parent = Holder Value1.Value = Stats[1] Value2.Value = Stats[2] Value3.Value = Stats[3] Value4.Value = Stats[4] Value5.Value = Stats[5]
Value2.Changed:connect(function() onXPChanged(player, Value2, Value1) end) Value1.Changed:connect(function() onLevelUp(player, Value2, Value1) end) player.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(player) while player ~= nil do wait(15) DataStore:SetAsync("Stats", {Value1.Value,Value2.Value,Value3.Value,Value4.Value,Value5.Value}) end end end)
game.Players.PlayerRemoving:connect(function(player) local Holder1 = player.leaderstats local Value1 = Holder1.Lvl -- change to name of stat if changed local Value2 = Holder1.XP -- change to name of stat if changed local Value3 = Holder1.Gold -- change to name of stat if changed local Value4 = Holder1.Tokens local Value5 = Holder1.Gems local DataStore = game:GetService("DataStoreService"):GetDataStore(player.userId) if Holder1 then if Value1 and Value2 and Value3 and Value4 and Value5 then DataStore:SetAsync("Stats", {Value1.Value,Value2.Value,Value3.Value,Value4.Value,Value5.Value}) end end end) end)
|
|
|
| Report Abuse |
|
|
| 23 Dec 2014 02:07 PM |
| Stat part works, there is no tool info yet. |
|
|
| Report Abuse |
|
| |