Issue with script, +Highlight

Hi, i was scripting for practice so i came face to face with problem, like nothing changes:
SERVER:

local ws = game:GetService("Workspace")
local rs = game:GetService("ReplicatedStorage")

local doorModel = ws:FindFirstChild("Door")
local mouseCheck = rs.RemoteEvents:FindFirstChild("MouseCheckEvent")

local parts = doorModel:GetChildren()

local function doorManagment()
	local listItems = {
		["Lock"] = "Key",
		["PassPart"] = "Card",
		["Board"] = "Scrap"
	}
	
	mouseCheck.OnServerEvent:Connect(function(player, target)
		for _, part in ipairs(parts) do
			for _, specialPart in ipairs(listItems) do
				local highlight = Instance.new("Highlight")
				highlight.DepthMode = Enum.HighlightDepthMode.Occluded
				highlight.FillColor = Color3.fromRGB(255, 255, 255)
				highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
				highlight.FillTransparency = 0.75
				highlight.Parent = specialPart
				highlight.Enabled = false
				
				if target == specialPart then
					highlight.Enabled = true
				else
					highlight.Enabled = false
				end
			end
		end
	end)
end

doorManagment()

CLIENT:

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

local mouseCheck = rs.RemoteEvents:FindFirstChild("MouseCheckEvent")
local player = ps.LocalPlayer
local mouse = player:GetMouse()

mouse.Move:Connect(function()
	local target = mouse.Target
	if target then
		mouseCheck:FireServer(target)
	end
end)


nothing. even no problems in output, idk what to do.

listitems is a table of strings, not objects

so.. yeah
make a table of those objects

Hi, @VovCatFlee.

Like HyperHunter said: listitems is table of strings, not objects.

Althought putting objects into table you might benefit from it but limits go in, so other way is you need change client’s sending data (with changes on Script (server-side) and LocalScript and adding ModuleScript which will be what is should be vaild to send and highlighting)

basically mouse when get target, also should gets target’s tag or attribute or name or whatever it is in method(-s) and if it has something equal to table of strings, it should send FireServer(targetitem) on RemoteEvent.

you can place ModuleScript (code opened to clients :frowning:) in ReplicatedStorage and change both scripts to follow ModuleScript’s table with some changes and it should work for server and clients

how? i was trying to do i do not understnad help

more complex for me, help me or explain by showing code or just more simplify it

yep, i did it, so can someone explain how i can organise the choosing system, like i can pick up all items, they will be like a tool and after in this part or idk:

local listItems = {
		["Lock"] = "Key",
		["PassPart"] = "Card",
		["Board"] = "Scrap"
	}

u can see which part can only be opened and after that item and part dissapear


waiting for help :blush:

You’re setting the parent to a string, aren’t you?

what do u mean by saying that, i did not take it.

You’re parenting highlights to string values instead of parts.

You have made a system where you parent a highlight to an object from a table in which you have strings of texts, not actual physical parts. Remove the strings and add the path to where the parts are located like, workspace.part etc.
And for the target check you write the condition as:

Target.Name == "specialpart"

i dont know how to realise it, nothing goes to my mind, absolutely.t

If that is the name of the part in the table then..

highlight.Parent = doorModel:WaitForChild(specialPart)

are u talking about door or items?

You’re overthinking this ..this is your table.

Here you’re looking for a match

for _, specialPart in ipairs(listItems)

But then you parent it to the item in the table.. That is a string not a part.
You need to parent to the part that stands for in the table.

right now i nedd to make like when i click somehow to the item i need i picked up it, and can hold it for now i can understand about “tool” how it works, i tried to type smth but i cant imagine how it should works properly.

part of code which i need somehow to check or idk really im very confused.. :

local items = ws.Items:GetChildren()
-- ...

pickUp.OnServerEvent:Connect(function(player, target) 
	for _, item in ipairs(items) do

	end
end)

hmmmmmmmmmmmmmm almost take it

Actually that sounds wrong what i just said too. Where is the part you’re looking to highlight at, in the players hand? Oh I see.. what is the full path to that Card, Key and scrap.. that is what you need here.
To aim it at the part you want to highlight.. not a string reference in a table without any other context of where it is.


i dont need highlight, highlight is for door’s part only, like now i need fix items (tool) idk how to make it like i need when i clicked on some of them i oicked up them to player Backpack

ok.. set up a local aimed at that part and parent the highlight to that.

should i use detector or mouse target? im thinking rn which case will be better and more easy