Help with saving decal & player

I’ve changed the local script, but it’s still not even printing.

1 Like

OH I FORGOT! You can’t use local scripts from workspace

1 Like

seems to work just fine so long as you put the local script somewhere where localscripts can work, and then re-define the prompt (obviously)

1 Like

Would ReplicatedStorage work? I don’t really know.

1 Like

I tried to put it in ReplicatedStorage and ServerScriptService, but still doesnt even print

1 Like

LocalScripts don’t work in either of those, I would recommend StarterGUI, or StarterPack because I know that both of those work

1 Like

I put it in startergui and it worked, but it says this:
image

2 Likes

did you remember to re-difine the frame?

1 Like

In changepainting?

local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("DecalData")
local Players = game:GetService("Players")
local FrameFolder = workspace.Frames
local Decals = {
	FrameFolder.FrameSM1,

}
local Plates = {
	FrameFolder.FrameSM1.MetalFrame,
}
while wait(1) do
	for i in pairs(Decals) do
		local data = DS:GetAsync(i)
		if data then
			local Plates = Plates[i]
			local decal = Decals[i]
			local ImgId = data[1]
			local Player = data[2]
			local PlayerName = Players:GetNameFromUserIdAsync(Player)
			Plates.Header.Donated.SurfaceGui.SIGN.Text = "This painting has been donated by:"
			Plates.Header.Giver.SurfaceGui.SIGN.Text = PlayerName
			decal.Image.Facer.Texture = ImgId
			
		end
	end
end
1 Like

no in the localscript when you’re sending the data

1 Like
local Players = game:GetService("Players")
local plr = Players.LocalPlayer

game.Workspace.Frames.FrameSM1.MetalFrame.Buy.Triggered:Connect(function()

	print(plr.UserId)

	local sendData = {
		1, -- change to be whatever number it coresponds to in the table in the "changepainting" script
		143751304,
		plr.UserId
	}

	game.ReplicatedStorage.RemoteEvent:FireServer(sendData)

end)
1 Like

I’m pretty sure I did it correctly.

1 Like

yeah you did, I don’t know what is causing this issue

1 Like

heres the script that has the error:

local Event = game.ReplicatedStorage.RemoteEvent

local DSS = game:GetService("DataStoreService")

local DS = DSS:GetDataStore("DecalData")

-- have it fire this event when the player purchases it

-- have the "data" variable (or whatever you name it) be a table containing the UserId of the player who purchased it, the Decal being edited, and the Decal Id (Decal first, Decal Id second, Player UserId third)

-- also make sure in the script for purchasing that the Decals in the table are in the same order

Event.OnServerEvent:Connect(function(data)

	print("caught")

	local DecalNumber = data[1]

	local DecalId = data[2]

	local UserId = data[3]

	local DataTable = { -- name this variable whatever you want

		DecalId,

		UserId

	}

	DS:SetAsync(DecalNumber, DataTable)

end)
1 Like

have you figured out anything? I haven’t lol.

1 Like

Try using a table in datasaving, you can save a lot with it.

1 Like
1 Like

I got it working, the problem is that the script keeps on loading it.

2 Likes

This is fairly simple enough, you can just save the asset ID of the decal & the userId of the player in 1 DataStore.

1 Like

Thanks to you, I have the game functional and working! All I need to do is build the museum and the game is done! You’ll definitely get credit for scripting.

1 Like