Gui Cloning Disappears when another person does the same event

I have a script, which clones a ui onto the persons frame when they use the proximity prompt. It works but when another person activates it it takes the icon away from the other person and gives it to the new player.
This is a script in serverscriptservice

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event1 = ReplicatedStorage.Perks:WaitForChild("JugHealth")
local Event2 = ReplicatedStorage.Remote:WaitForChild("CloneEvent1")

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")	

		local JugIcon = game.ServerStorage.Perks.Juggernog
		local clonedJug = JugIcon:Clone()
		
Event2.OnServerEvent:Connect(function(plr)
	print("CloningJugIcon")
			clonedJug.Parent = plr.PlayerGui.Perks.Frame
			end)
end)
end)

Would you care to elaborate on that statement?

What do you want to achieve, what’s the problem, and have you tried any other solution? Make sure they’re separated in new lines, so I don’t get mixed with achievement and the problem.

If you want to clone a ui using events you should do fire the event on the server and clone it in the client.

I’m trying to make a perk like system from the call of duty zombies franchise, right now it gives the cloned ui icon when the person used the proximity prompt, which activates the event. But when another person activates the proximity prompt, the cloned ui disappears from the original persons ui and gives itself to the new player. I’m trying to make it so that when one person uses the prompt, that person gets the ui, and when another person uses the prompt, it also gives the person the ui, without taking the ui away from the other person.

but the icon is in serverstorage, so i’d need to use a script to clone it

Why not move it to replicated storage?

This text is blurred

On receiving the event, you’re getting the plr argument inside the function, and the clonedJug is being parented to that player’s GUI.

Does this fix your problem?

Event2.OnServerEvent:Connect(function()
	print("CloningJugIcon")
	clonedJug.Parent = plr.PlayerGui.Perks.Frame
end)

nope, instead it gives it to everybody, instead of the player

Clone it when the event fires.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character()
        local character: Model = player.Character or player.CharacterAdded:Wait()
        local humanoid: Humanoid = character:WaitForChild("Humanoid")
    end)
end)

Event2.OnServerEvent:Connect(function(player)
    print("Cloning Jug Icon")
    local clonedJug = game.ServerStorage.Perks.Juggernog:Clone()
    clonedJug.Parent = player.PlayerGui.Perks.Frame
end)
1 Like

Otherwise - If you really need to clone it into the character first, make a folder in the Player, keep the label there and move it when you need it:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character()
        local character: Model = player.Character or player.CharacterAdded:Wait()
        local humanoid: Humanoid = character:WaitForChild("Humanoid")

        local perksFolder = Instance.new("Folder")
        perksFolder.Name = "Perks"
        perksFolder.Parent = player
        local clonedJug = game.ServerStorage.Perks.Juggernog:Clone()
        clonedJug.Parent = player:WaitForChild("Perks")
    end)
end)

Event2.OnServerEvent:Connect(function(player)
    print("Cloning Jug Icon")
    local clonedJug = player:WaitForChild("Perks"):WaitForChild("Juggernog"):Clone() -- Clone is not needed, but you can do it if you want
    clonedJug.Parent = player.PlayerGui.Perks.Frame
end)
1 Like

This one worked, Thank you very much !!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.