Clone the ui to another player when pressed the button

  1. What do you want to achieve? I want to clone the ui to the target player.

  2. What is the issue? Doesnt clone the ui to target player.

  3. What solutions have you tried so far? No solutions.

local player = game.Players.LocalPlayer
local AssignFrame = script.Parent.AssignFrame
local AssignedFrame = script.Parent.Assigned
local Username_Frame = script.Parent.AssignFrame.Username
local mouse = player:GetMouse()
--Department Button
local GC = AssignFrame.GC
local CC = AssignFrame.CC
local CPT = AssignFrame.Captain
local FO = AssignFrame.FO
local Supervsor = AssignFrame.Supervisor
local CoHost = AssignFrame["Co-Host"]
--Main Button Works
mouse.Button1Down:Connect(function()
		local target = mouse.Target
		if target.Parent:FindFirstChild("Humanoid") and target.Parent ~= game.Workspace then
		Username_Frame.Text = target.Parent.Name
		GC.MouseButton1Click:Connect(function()
			target.AssignedFrame:Clone()
			Username_Frame.Text = "It worked."
		end)
	end
end)

  1. you are doing it in the client so the other client wont see it
  2. you didn’t even parent the cloned instance
solution 1
  • get an events folder
  • and then put in a remote event inside the events folder and name it ShowUI idk that’s the first thing I think of

image

server script on serverscriptservice

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local events = ReplicatedStorage:WaitForChild("Events")

events:WaitForChild("ShowUI").OnServerEvent:Connect(function(Player, Target, Gui)
	local ClonedGui = Gui:Clone()
	ClonedGui.Parent = Players:FindFirstChild(Target):FindFirstChildOfClass("ScreenGui") -- I dont know where to put it
end)

client thing

local player = game.Players.LocalPlayer
local AssignFrame = script.Parent.AssignFrame
local AssignedFrame = script.Parent.Assigned
local Username_Frame = script.Parent.AssignFrame.Username

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local events = ReplicatedStorage:WaitForChild("Events")
local addTarget = events:WaitForChild("ShowUI")

local mouse = player:GetMouse()
--Department Button
local GC = AssignFrame.GC
local CC = AssignFrame.CC
local CPT = AssignFrame.Captain
local FO = AssignFrame.FO
local Supervsor = AssignFrame.Supervisor
local CoHost = AssignFrame["Co-Host"]
--Main Button Works
mouse.Button1Down:Connect(function()
	local target = mouse.Target
	if target.Parent:FindFirstChild("Humanoid") and target.Parent ~= game.Workspace then
		Username_Frame.Text = target.Parent.Name

		GC.MouseButton1Click:Connect(function()
			Username_Frame.Text = "It worked."
			addTarget:FireClient(player, target.Parent.Name,target.AssignedFrame)
		end)
	end
end)
solution 2

change the script into a server script instead of a local script

1 Like

Remember to add checks or exploit proof. If an exploiter managed to hijack your remotes then anybody would be able to send any UIs to be cloned to any player… that would not end very well!

1 Like

What should I do if my UI is visible is on.