Hello there,
-- Server - Client Function -- local rs = game:GetService("ReplicatedStorage") local folder = rs:WaitForChild("Instance Work") local instance_func = folder:WaitForChild("Instance") ------------------------------------------------------ -- Creates a part on the server -- local function instance(plr, obj, props) local object = Instance.new(obj) for prop, value in next, props do if prop == 'Parent' then value = return_obj_from_string(value) end object[prop] = value end if object then return object end end instance_func.OnServerInvoke = instance -- Creates a part on the server -- ------------------------------------------------------
-- Client - Server Function -- local rs = game:GetService("ReplicatedStorage") local folder = rs:WaitForChild("Instance Work") local instance_func = folder:WaitForChild("Instance") ------------------------------------------------------ -- Creates a part on the client -- local function instance(obj, props) local object = Instance.new(obj) for prop, value in next, props do if prop == 'Parent' then value = return_obj_from_string(value) end object[prop] = value end if object then return object end end instance_func.OnClientInvoke = instance -- Creates a part on the client -- ------------------------------------------------------
-- Script inside Click Detector, which is inside a part and meant to activate the client function upon clicking the part -- local detector = script.Parent; local rs = game:GetService("ReplicatedStorage"); local instance_folder = rs:WaitForChild("Instance Work") local instance = instance_folder:WaitForChild("Instance") detector.MouseClick:Connect(function(plr) local char = plr.Character or plr.CharacterAdded:Wait(); local root = char:WaitForChild("HumanoidRootPart"); local props = { ['BrickColor'] = BrickColor:random(); ['Transparency'] = math.random(); ['Anchored'] = true; ['CanCollide'] = false; ['Material'] = Enum.Material.Neon; ['CFrame'] = root.CFrame; ['Parent'] = workspace; ['Name'] = 'Innovation'; } print("It is:", instance:InvokeClient(plr, 'Part', props)) -- Prints "It is: nil" end)
Best regards,
IdealistDeveloper