Hello there, ive been attempting to create a script that inserts a clickdetector into the players torso alowing other players to hover there mouses over the other players to view there name and if they click it will open up a trading gui.
I am here today asking how i can fix my script. I am only looking for a correction on the inserting portion. Here is what i have
game.Players.PlayerAdded:connect(function(plr)
local detector = Instance.new('ClickDetector', plr.Character.HumanoidRootPart)
detector.Name = "detector"
end)
Now, i was wondering if it would be more efficiant to clone one with a pre made script that open does the name and trading part. Or should i use instance.new.
Please fix my script and tell me wich way would br more efficiant. If i were to clone i would try this(clickdetector is in replicatedfirst with a premade script alowing it to open the trading gui when clicking the torso of another player)
local service = game:GetService('ReplicatedFirst')
game.Players.PlayerAdded:connect(function(plr)
service:FindFirstChild('ClickDetector'):Clone().Parent = plr.Character.HumanoidRootPart
end)
This way it would already have a script in it
Thank you for reading

1 comment
Use instance.new it is just as efficient as cloning the detector into the torso.