Hello, I have had to do similar things where I had to duplicate something to the client, and I have a basic script(s) that I can give to you. It is not complete, but is easy to improve. All you need to do is the following:
Create a remote event in ReplicatedStorage called “CSRBridge”
Pretty simple. You can change the name, but you must also change the name in the scripts.
Put the following code in a localscript called “CSRReceiver”
Put this in local player scripts. This changes everything on the client
-- Services
local Players = game:GetService("Players");
local ReplicatedStorage = game:GetService("ReplicatedStorage");
-- Remotes
local CSRBridge = ReplicatedStorage:WaitForChild("CSRBridge");
-- Variables
local localPlayer = Players.LocalPlayer;
-- Events
CSRBridge.OnClientEvent:Connect(function(_variation, ...)
local xArgs = {...};
if(_variation == "DUPLICATE") then
local object = xArgs[1];
local name = xArgs[2] or object.Name;
local parent = xArgs[3] or object.Parent;
local clientObject = object:Clone();
clientObject.Name = name;
clientObject.Parent = parent;
elseif(_variation == "PROPERTY") then
local object = xArgs[1];
local propertyName = xArgs[2];
local newValue = xArgs[3];
object[propertyName] = newValue;
end
end)
Use this module script to easily communicate with the client. Use this on a server script
This module script abstracts the local script and allows you to easily work with little risk of error
-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage");
-- Remotes
local CSRBridge = ReplicatedStorage:WaitForChild("CSRBridge");
-- Variables
local replicator = {};
local mt = {__index = replicator};
-- Events
function replicator.new(_player) -- Create a new replicator instance
local self = setmetatable(replicator, mt);
self.player = _player;
return self;
end
function replicator:Duplicate(_object, _name, _parent) -- Duplicate the object on the client
CSRBridge:FireClient(self.player, "DUPLICATE", _object, _name, _parent);
end
function replicator:ChangeProperty(_object, _propertyName, _newValue)
CSRBridge:FireClient(self.player, "PROPERTY", _object, _propertyName, _newValue);
end
return replicator; -- Return
Hopefully I understood what you needed to do, and that this helps. Obviously this only a basic template, but is easily expandable. Feel free to edit it
Edit:
In the case you don’t understand how to use it, here is an example server script that uses the module script. It should show the syntax of the module
-- Services
local Players = game:GetService("Players");
-- Modules
local ClientSideReplicator = require(script.ClientSideReplicator);
-- Variables
local testPart = script.ref.Value;
local dump = script.dump.Value;
-- Events
Players.PlayerAdded:Connect(function(_localPlayer)
local csr = ClientSideReplicator.new(_localPlayer);
csr:ChangeProperty(testPart, "Transparency", 0.5);
csr:Duplicate(testPart, "Did it work?", dump);
end)