Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't my DataStore saving and how would I fix this?

So basically, I made a short project in which a player's JumpPower is increased per click, here are the two scripts:

local datastore = game:GetService("DataStoreService")
local powerStore = datastore:GetDataStore("powerStore")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"
	
	local power = Instance.new("IntValue", leaderstats)
	power.Name = "Power"
	
	local savedata
	local s, f = pcall(function()
		savedata = powerStore:GetAsync(player.UserId)
	end)
	
	if s then
		power.Value = savedata
		print("data successfully loaded")
	else 
		print("data not loaded")
	end
	
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.JumpHeight = power.Value
	end)
end)

game.Players.PlayerRemoving:Connect(function(player)
	local s, f = pcall(function()
		powerStore:SetAsync(player.UserId, player.leaderstats.Power.Value)
	end)
	
	if s then
		print("data successfully saved")
	else 
		print("data not saved")
	end
end)

^ thats the datastore

and this is the GUI:

local button = script.Parent

button.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.leaderstats.Power.Value += 1
	game.Players.LocalPlayer.Character.Humanoid.JumpHeight = game.Players.LocalPlayer.leaderstats.Power.Value
end)


When I go in the game, and use F9 to change the value of the power, the datastores works just fine and saves the value, however when I use the button to increase it, then it doesn't save/load anything.

1 answer

This is due to Filtering Enabled.

Filtering Enabled prevents changes on the client to replicate to the server. Your "Power" value is only being changed on your client and will not be changed on the server. To change it on the server, you can use a Remote Event.

This discussion is preserved as it was. New answers, comments, and votes are closed.