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)
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 ) in ReplicatedStorage and change both scripts to follow ModuleScript’s table with some changes and it should work for server and clients
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:
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:
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.
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