I am making an odometer that should save, but when I join back, it says 0 (the original value)!
local DataStore2 = require(1936396537)
game:GetService("Players").PlayerAdded:Connect(function(plr)
local kilometre_ = "kilometre_"
wait(2)
local kilometreData = DataStore2(kilometre_, plr)
local kilometre = game.Workspace["DAF XF"].Body.DashBoard.SurfaceGui.RPM.Odometer.Script.km.Value
local success, errorMessage = pcall(function()
kilometre = kilometreData:Get() or 0
end)
if success then
print("Data successfully loaded")
kilometre = kilometreData
else
print("There was an error loading the data: " .. errorMessage)
plr:Kick("Couldnt load data. Initiating Client Kicking. Expierience Error Code: 0x1936396537f")
end
end)
game.Workspace["DAF XF"].Body.DashBoard.SurfaceGui.RPM.Odometer.Script.km.Changed:Connect(function()
wait(2)
local plr = game.Players:FindFirstChildWhichIsA("Player")
local kilometre_ = "kilometre_"
if plr == nil then
else
local kilometreData = DataStore2(kilometre_, plr)
local success, errorMessage = pcall(function()
kilometreData:Set(game.Workspace["DAF XF"].Body.DashBoard.SurfaceGui.RPM.Odometer.Script.km.Value)
end)
if success then
print("Data successfully saved")
else
plr.PlayerGui.UI.NotificationText.Text = "Data wasnt saved. Expierience Error Code: 0x1936396537b"
end
end
end)