SOmeone found a way to use the click detector even when a tool is equipped so I used it, I made a remote event (client - server) that change the value of opened to true if used with a certain key color, but it somewhat doesnt change the value even if the string are the same
local script
local Tool = script.Parent
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
ocal colorString = "Yellow"
Tool.Activated:Connect(function()
if Tool.Equipped then
if Mouse.Target and Mouse.Target:FindFirstChild("ClickDetector") then
if (Tool.Handle.Position - Mouse.Target.Position).Magnitude <= Mouse.Target.ClickDetector.MaxActivationDistance then
game.ReplicatedStorage.KeyOpen:FireServer(tostring(colorString))
end
end
end
end)
server script
local OpenValue = script.Parent.Opened
game.ReplicatedStorage.KeyOpen.OnServerEvent:Connect(function(color)
if color == script.Parent.KeyColor.Value then
OpenValue.Value = true
end
end)
remote event name: KeyOpen
color value inside tool: Yellow
key color inside keyhole: Yellow (I