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.
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)
There you go i replaced the line in the script i sent you with the info you gave me
ok so i put this on CharacterStarterScripts or i should add your line on leaderstats?
Im Very Confused now i dont know where to start im stucked on NumberValue dont know what to do. I need your guide in the beggining to the last
dont worry ill help!
can i send you my project and check it?
This discussion is preserved as it was. New answers, comments, and votes are closed.
14 comments
This will not work since .Health returns its current health and not the actual property. To fix this, just set a variable to the Humanoid then do Humanoid.Health = WhateverHere .
^^ To clarify, you cannot set a variable to a property because it will just retain the value that the property is set to (and does not update) and not the actual property itself.
Ew, im new to these scripting stuff, sorry for the incovenience xd, thank you anyway
Humanoid = game:GetService("Players").LocalPlayer.Humanoid Health = Humanoid.Health Souls = Souls Health = Souls its not work
what do you mean "here you place the location of the object" sorry im bad in english
You have to create a NumberValue (Object) in the game/Workspace and say to the game where it is.Example: If placed it in the workspace i should type game.Workspace.Value (Value is the name of the object) in there.And you can create this "NumberValue" object simply by right clicking on something and then inserting it.
ok but its a localscript or a normal script?
Local
ok i create a NumberValue on workspace the what should i do?
i got this error
19:39:22.532 - Humanoid is not a valid member of Player 19:39:22.533 - Stack Begin 19:39:22.533 - Script 'Workspace.pukinginakatalaga.LocalScript', Line 1 19:39:22.534 - Stack End
i should put some script on NumberValue?
20:24:03.205 - leaderstats is not a valid member of Model 20:24:03.206 - Stack Begin 20:24:03.206 - Script 'Workspace.pukinginakatalaga.LocalScript', Line 4 20:24:03.207 - Stack End
Can i give you my project pls fix it for me much appreciate very much its been more than 2 weeks im stucked on this problem