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)
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.
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.
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)
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)