How could I make it save?

image

image

Alright, so this might be annoying but youā€™ll have to change the scripts for the toolsā€¦
Iā€™ll tell you in a minute

The tools do not have a script at all.
image

Only the scripts inside of ItemNeededScripts are where the tool is used. Example of one of the scripts:

local plank = game.Workspace.ItemNeeded.PlankNeeded1
local db = false
plank.Touched:Connect(function(Hit)
	if db == false then
		db = true
	end
	if Hit.Parent.Name == "Plank" then
		plank.CanCollide = true
		plank.BillboardGui1:Destroy()
		plank.Transparency = 0
		Hit.Parent:Destroy()
		wait(0.5)
		script:Destroy()
		db = false
	end
end)

Ah ok, Iā€™m going to send the new version of the data store thing, then Iā€™ll show you an example.

I use this script for my games, completely made by me.

So in the script for the door, do

local DataModule = require(game:WaitForChild("ReplicatedStorage"):WaitForChild("DataModule"))

then when the door is unlocked put

DataModule.SetSpecificPlayerData(Player.Name, String, Value)

the string is the value to set for ex. Plank_1_Unlocked.

You can also request data from the module, that can be used to unlock the previously unlocked doors when the player joins.

1 Like

Ah okay. Do you just want me to make a model with the stuff and scripts, so it can be easier for you to categorize them?

I honestly would just say you know, let me implement it into your gameā€¦ but I donā€™t want to be rude / invading. If you want sure?

If you want, I can implement it into your game.

Here is just a model of the current tool things in my game. Let me know when you got it.

1 Like

Alright so if you can also hand me the doors (sorry lol) I can create the system to go along with that.

The doors? Like the ice key, pickaxe, and bombs? If so, they are in the model.

Oh sorry, I didnā€™t see that lol.

1 Like

Alright all you gotta do is put this model back to its place and it should work, lemme know otherwise and Ill try to fix it.

1 Like

So, do I still keep the ItemNeededScripts?

image

hold on I think I forgot to do something
lemme check one sec

Alright, now just put replace the item needed scripts with this modelā€™s item needed scripts:

One more question, shouldnt do remote event go into replicatedstorage?

image

No that is for the blocks only being invisible for the client, speaking of that I also forgot one other thing which is an easy fix (sorry im tired lol) one sec ill get back to you.

1 Like

Replace the datastore script in serverscript service with this code

local DataModule = require(game.ReplicatedStorage.DataStoreModule)
local DSS = game:GetService("DataStoreService")
local PlayerDataStore = DSS:GetDataStore("PlayerData")

game.Players.PlayerAdded:Connect(function(Player)
	local Success, Data = pcall(function()
		return PlayerDataStore:GetAsync(Player.UserId)
	end)
	warn("Success:", Success)
	warn("Data:", Data)
	if Success and Data then
		DataModule.SetPlayerData(Player.Name, Data)
	elseif Success and not Data then
		warn("Unable to get "..Player.Name.."'s data, they are a new player!")
		DataModule.SetPlayerDataDefault(Player.Name)
	elseif not Success and not Data then
		Player:Kick("Error while connecting to roblox datastore, please rejoin or try again later.")
		error("Unable to get "..Player.Name.."'s data, unable to connect to datastores.")
	end
	
	for i, v in pairs(Data) do
		if workspace:FindFirstChild(i) ~= nil then
			if v == true then
				Player.PlayerScripts:WaitForChild("UnlockEvent"):FireClient(Player, workspace:FindFirstChild(i))
			end
		end
	end
end)

game.Players.PlayerRemoving:Connect(function(Player)
	local PlayerData = DataModule.RequestPlayerData(Player.Name)
	
	if PlayerData ~= nil then
		warn("Saving "..Player.Name.."'s Player data as", PlayerData)
		local Success, ErrorCode = pcall(function()
			PlayerDataStore:SetAsync(Player.UserId, PlayerData)
		end)
		if not Success then
			warn(ErrorCode)
		else
			local Success, Data = pcall(function()
				PlayerDataStore:GetAsync(Player.UserId)
			end)
			warn(Data)
		end
	end
end)

Thank you, but there is a bit of a problem. For the planks, I can not place them at all.

Ah ok can you send me any errors in the output?

There doesnā€™t seem to be any errors. Only a warning. (Ignore the SetPartCollisionGroup, it is a different thing)