Hello. I am creating a picture frame that when you buy it, it saves the decal forever. Right now, I am having a problem with it.
script 1 inside ServerScriptService (server)
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)
script 2 in serverscriptservice (server) :
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
local script in starterGui:
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)
the error: