on my case i want to use souls value to be the localPlayers heath
Example:
player have 1000 souls then when player have 0 souls the charcter will die and where can i put the script? thanks
sorry but im a newbie.
Try doing:
Player = game:GetService("Players").LocalPlayer Humanoid = Player.Character.Humanoid Health = Humanoid.Health Souls = Humanoid.Parent.leaderstats.Souls Health = Souls
That could go in CharacterStarterScripts
Pretty simple and might work.Probally.
So mine is "game.ServerScriptService.leaderstats" -- the souls value is inside "leaderstats" and the script leaderstats is inside "ServerScriptService"
Humanoid = game:GetService("Players").LocalPlayer.Humanoid Health = Humanoid.Health Souls = game.ServerScriptService.leaderstats -- So is This correct? Health = Souls
This is my leaderstats
local serverStorage = game:GetService("ServerStorage") local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSave3")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" leaderstats.Parent = player local souls = Instance.new("IntValue",leaderstats) souls.Name = "Souls" -- THIS IS THE SOUL IM TALKING ABOUT souls.Parent = leaderstats souls.Value = 0 local strength = Instance.new("NumberValue") strength.Name = "Strength" strength.Parent = leaderstats local rebirth = Instance.new("IntValue",leaderstats) rebirth.Name = "Rebirth" rebirth.Parent = leaderstats rebirth.Value = 0 local dataFolder = Instance.new("Folder") dataFolder.Name = player.Name dataFolder.Parent = serverStorage.RemoteData local debounce = Instance.new("BoolValue") debounce.Name = "Debounce" debounce.Parent = dataFolder local strengthData, rebirthData, soulsData local success,errormessage = pcall(function() strengthData = DataStore:GetAsync("strength-"..player.UserId) rebirthData = DataStore:GetAsync("rebirth-"..player.UserId) soulsData = DataStore:GetAsync("souls-"..player.UserId) end) if success then if strengthData then strength.Value = strengthData rebirth.Value = rebirthData souls.Value = soulsData end end
end)
game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value) DataStore:SetAsync("rebirth-"..player.UserId,player.leaderstats.Rebirth.Value) DataStore:SetAsync("souls-"..player.UserId,player.leaderstats.Souls.Value) end) end)