Then add a DataStore, since you don’t have one, and add it to the 1st line, it’s quite important.
(Sorry Wrong Reply)
I already have it
local playerData = DataStoreService:GetDataStore("PlayerData")
```
Can you show the Full DataStore? (Not the script I want the DataStore.)
you searched up the wrong term, It should be DataStoreService
, not multiplierST.Value
this is the right term
DataStoreService
this is the wrong term
multiplierST.Value
local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("PlayerData")
local function onPlayerJoin(player) -- Runs when players join
local playerUserId = "Player_" .. player.UserId -- Gets player ID
local data = playerData:GetAsync(playerUserId) -- Checks if player has stored data
if data then
Strength.Value = data['Strength']
Defense.Value = data['Defense']
multiplierST.Value = data['MultiplierST']
else
-- Data store is working, but no current data for this player
Strength.Value = 0
Defense.Value = 0
multiplierST.Value = 1
end
end
local function create_table(player) -- Deal with playerstats
local player_stats = {}
player_stats['Defense'] = player.leaderstats.Defense.Value
player_stats['MultiplierST'] = player.Multipliers.MultiplierST.Value
player_stats['Strength'] = player.leaderstats.Strength.Value
return player_stats
end
local function onPlayerExit(player) -- Runs when players exit
local player_stats = create_table(player)
local success, err = pcall(function()
local playerUserId = "Player_" .. player.UserId
playerData:SetAsync(playerUserId, player_stats) -- Saves player data
end)
if not success then
warn('Could not save data!')
end
end```
Remove that, and do this to this line:
local DataStore = game:GetService("DataStoreService"):GetDataStore("The Random Data")
Also, please do not do as a function, it’ll not work.
Put it on a Player Loading Service:
local DataStore = game:GetService("DataStoreService"):GetDataStore("The Random Data")
-- Player Loading Process
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"
local Strength = Instance.new("NumberValue", leaderstats)
Strength.Value = 0
Strength.Name = "Strength"
local Defense= Instance.new("NumberValue", leaderstats)
Defense.Value = 0
Defense.Name = "Defense"
local Multipliers = Instance.new("Folder", Player)
Multipliers .Name = "Multipliers "
local multiplierST = Instance.new("NumberValue", Multipliers)
multiplierST.Value = 0
multiplierST.Name = "Multiplier Strength"
local dataload = DataStore:GetAsync(tostring(Player.UserId())
-- Function pcall Response, Success and/or Error.
local Success, Response = pcall(function()
if dataload == nil then
print("Dataload and the Data itself is nil! This is absurd!")
end
return Data, dataload, Strength, Defense, multiplierST
end)
task.wait(0.4)
if dataload then
Strength.Value = dataload[1]
Defense.Value = dataload[2]
multiplierST.Value = dataload[3]
elseif not dataload then
warn("We're sorry but the stats has failed to process and function, as the pcall function said, it's nil.")
end
end)
-- Player Removing System.
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(tostring(Player.UserId),{
Player.leaderstats.Strength.Value,
Player.leaderstats.Defense.Value,
Player.leaderstats["Multiplier Strength"].Value
})
end)
Your script will not work since I changed the Value Name.
local strengthAdd = 5
local defenseAdd = 5
local healthIncrease = 2
while wait(1) do
local char = player.Character
if char then
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + (strengthAdd * player.Multipliers["Multiplier Strength"].Value)
player.leaderstats.Defense.Value = player.leaderstats.Defense.Value + defenseAdd
humanoid.Health = player.leaderstats.Defense.Value + healthIncrease
humanoid.MaxHealth = player.leaderstats.Defense.Value + healthIncrease
end
end
end
The data store worked great, but still returning 0 for the [“Multiplier Strengh”].Value
I guess, its a bug. Anyways, thanks for the support, ill be reaching out bug support
local DataStore = game:GetService("DataStoreService"):GetDataStore("The Random Data")
-- Player Loading Process
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"
local Strength = Instance.new("NumberValue", leaderstats)
Strength.Value = 0
Strength.Name = "Strength"
local Defense= Instance.new("NumberValue", leaderstats)
Defense.Value = 0
Defense.Name = "Defense"
local Multipliers = Instance.new("Folder", Player)
Multipliers.Name = "Multipliers"
local multiplierST = Instance.new("NumberValue", Multipliers)
multiplierST.Value = 1
multiplierST.Name = "Multiplier Strength"
local dataload = DataStore:GetAsync(tostring(Player.UserId())
-- Function pcall Response, Success and/or Error.
local Success, Response = pcall(function()
if dataload == nil then
print("Dataload and the Data itself is nil! This is absurd!")
end
return Data, dataload, Strength, Defense, multiplierST
end)
task.wait(0.4)
if dataload then
Strength.Value = dataload[1]
Defense.Value = dataload[2]
multiplierST.Value = dataload[3]
print("The Data has successively loaded, which means, the Stats also loaded!")
elseif not dataload then
warn("We're sorry but the stats has failed to process and function, as the pcall function said, it's nil.")
end
if multiplierST.Value == 0 then
warn(multiplierST.Name.."'s Value is 0, it's a bug."
end
end)
-- Player Removing System.
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(tostring(Player.UserId),{
Player.leaderstats.Strength.Value,
Player.leaderstats.Defense.Value,
Player.leaderstats["Multiplier Strength"].Value
})
end)
I forgot that the Values were at 0.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.