Seems like you have 2 CharacterAdded event, which I don’t see why you need. Also, the parameter of the CharacterAdded is the character, so you can just do:
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
local AUTOSAVE_INTERVAL = 60
local VIPid = 9456079
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Parent = leaderstats
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Parent = leaderstats
local Activations = Instance.new("IntValue")
Activations.Name = "Activations"
Activations.Parent = leaderstats
local Deaths = Instance.new("IntValue")
Deaths.Name = "Deaths"
Deaths.Parent = leaderstats
local Upgrades = Instance.new("Folder")
Upgrades.Name = "Upgrades"
Upgrades.Parent = player
local SpeedLevel = Instance.new("IntValue")
SpeedLevel.Name = "SpeedLevel"
SpeedLevel.Parent = Upgrades
local JumpLevel = Instance.new("IntValue")
JumpLevel.Name = "JumpLevel"
JumpLevel.Parent = Upgrades
local maxSpeed = Instance.new("IntValue")
maxSpeed.Name = "maxSpeed"
maxSpeed.Parent = player
local maxJump = Instance.new("IntValue")
maxJump.Name = "maxJump"
maxJump.Parent = player
local CurrentSpeed = Instance.new("IntValue")
CurrentSpeed.Name = "CurrentSpeed"
CurrentSpeed.Parent = player
local CurrentJump = Instance.new("IntValue")
CurrentJump.Name = "CurrentJump"
CurrentJump.Parent = player
local Multiplier = Instance.new("NumberValue")
Multiplier.Name = "Multiplier"
Multiplier.Parent = player
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPid) then
Multiplier.Value = 1.5
else
Multiplier.Value = 1
end
-->> Data: Begining
local playerUserId = "Player_"..player.UserId
-->>Data: Load Data
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
end)
if success then
if data then
Points.Value = data.Points
Wins.Value = data.Wins
Activations.Value = data.Activations
Deaths.Value = data.Deaths
SpeedLevel.Value = data.SpeedLevel
JumpLevel.Value = data.JumpLevel
maxSpeed.Value = data.maxSpeed
maxJump.Value = data.maxJump
CurrentSpeed = data.CurrentSpeed
CurrentJump = data.CurrentJump
Multiplier = data.Multiplier
else
CurrentSpeed = 16
CurrentJump = 50
end
end
player.CharacterAdded:Connect(function(char)
char.Humanoid.WalkSpeed = CurrentSpeed.Value
char.Humanoid.JumpPower = CurrentJump.Value
end)
end)