So, i am making a painting gui in roblox and i want to send the painting frame to the server from the client so everybody can see, thus the problem is that the frame only shows the descendants to the client player, now i add a waiting time, it deletes, then comes back with the painting pieces only for me (if i was the one painting), but it doesn’t show for the other players and same problem with others
client:
function sendDataToServer(data)
game.ReplicatedStorage.ReturnPainting:InvokeServer(data)
end
script.Parent.Parent.Exit.MouseButton1Up:Connect(function()
sendDataToServer(canvas)
end)
(test) Server:
game.ReplicatedStorage.ReturnPainting.OnServerInvoke = function(Player, data)
local paintingFrame = data-- Create the painting frame based on the received data
paintingFrame.Parent = game.Workspace
end
Generally, as a rule, I wouldn’t pass an object through remotes, instead, I would serialize the data and send it to the server. Take note that the data should be validated to prevent hacks from taking place on the server.
Your code for painting is client-sided, hence, other players will not see what the painter paints on the canvas. You cannot simply send the canvas instance to the server for other players to see.
You might have to redesign your code responsible for painting on the canvas.
Whenever the player paints on the canvas, you can save the:
Position of the paint
Color of the paint
Put all of this data into a table and send this table to the server through a remote. On the server script, create code to create paint on the canvas based on the data received from the player.
Your idea is correct, but it can be simplified to this:
local CanvasData = {
{X,Y,Color},
{X,Y,Color},
--and so on
}
Then when you send this table to server, you can recreate the canvas with code like this:
for _, Piece in pairs(data) do
local NewPiece = Instance.new("Frame")
NewPiece.Parent = Canvas
NewPiece.Position = UDim2.new(0, Piece[1],0, Piece[2]) --not sure if this is right, I'm just working from what I remember
NewPiece.Color3 = Piece[3]
end
I’m not sure what that means, but I’m guessing you’re sending data too frequently. Remotes have a built-in cooldown to prevent spamming so you should try slowing down the refresh rate of the canvas.