mouse.Target has same name as other objects

I know, A weird title but I don’t know how to explain so I’m just gonna show you the scripts:

  • This is the one in my tool

script.Parent.Activated:Connect(function()

local player = game.Players.LocalPlayer
local char = game.Workspace:FindFirstChild(player.Name)
local head = char:WaitForChild('Head')
local mouse = player:GetMouse()
local target = game.Workspace:FindFirstChild(mouse.Target.Name)
local namevar = Instance.new('')
local MAXDIS = 60


if mouse.Target:FindFirstChild('Killable') and target then
	


	player.PlayerGui.ArrowUI.Enabled = true
	player.PlayerGui.ArrowUI.Adornee = mouse.Target:FindFirstChild('navigate')

	script.shoot:FireServer(target)
	

	

	
	
end

end)
Now the problem here is that my target is called ‘doll’ but I have more than 1 object called doll in the workspace. How can I make sure I got the right one?

1 Like

You can open an unique attributation for the part and then you can check it with a code maybe?
Or you can check it’s parent, transparency, child, blockcolor or any other specific stat.

I was thinking that first too but I just think the problem here is that all the dolls have the same name, parent, color, transparency,… so it is really hard to do this.

Give an unique attribute
image
You can randomly give name if you want. It’s up to you.
image
Then you can check it with code.
image

or you can give a number for all dolls and name the string DollNumber

Then check which doll is that easy.

1 Like

And just make for every doll an unique attribute? I think this could work. Thanks a lot!

2 Likes

You are welcome. Enjoy it!

If you can sellect me as solution. I appreciate it :slight_smile:

Also this document Instance Attributes | Documentation - Roblox Creator Hub will help you for sure.

1 Like

Thank you, I’m scripting for 1 year now so I’m still learning. Oh I thought i did, I’m sorry :slight_smile:

2 Likes

It’s okay no need to apologize. I’m not pro too. Good luck on your path :slight_smile:

2 Likes

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