I was making an item pickup system which basically consists of a script in a model that is a fake clone of a tool (like a knife). It has a clickdetector and a highlight inside of it. When the mouse hovers over it it enables the Highlight and when it leaves, it disables.
My issue is that I also have drawers using a similar script on their handles. It enables a highlight on the handle then opens when clicked. For someone reason the highlight appears on multiple object, for example when I hover over a handle, both the handle and the knife get highlighted.
robloxapp-20231020-1340528.wmv (3.5 MB)
Solutions I’ve tried was to check for any other scripts that could be interfering, didn’t find any. My only idea is that it could be an issue with Roblox itself.
Drawer Script:
local cd = script.Parent.Union.ClickDetector
local highLight = script.Parent.Union.Highlight
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local openTween = TweenService:Create(script.Parent.Union, TweenInfo.new(0.5), {Position = Vector3.new(126.519, 1.317, 31.589)})
local closeTween = TweenService:Create(script.Parent.Union, TweenInfo.new(0.5), {Position = Vector3.new(126.519, 1.317, 29.589)})
cd.MouseHoverEnter:Connect(function(Player)
highLight.Enabled = true
end)
cd.MouseHoverLeave:Connect(function(Player)
highLight.Enabled = false
end)
cd.MouseClick:Connect(function(Player)
if script.Parent.Union.Position == Vector3.new(126.519, 1.317, 29.589) then
openTween:Play()
else
closeTween:Play()
end
end)
Item Script:
local cd = script.Parent.Union.ClickDetector
local highLight = script.Parent.Union.Highlight
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local openTween = TweenService:Create(script.Parent.Union, TweenInfo.new(0.5), {Position = Vector3.new(126.519, 2.607, 31.589)})
local closeTween = TweenService:Create(script.Parent.Union, TweenInfo.new(0.5), {Position = Vector3.new(126.519, 2.607, 29.589)})
local tool = game.ReplicatedStorage.Donut:Clone()
cd.MouseHoverEnter:Connect(function(Player)
highLight.Enabled = true
end)
cd.MouseHoverLeave:Connect(function(Player)
highLight.Enabled = false
end)
cd.MouseClick:Connect(function(Player)
if script.Parent.Union.Position == Vector3.new(126.519, 2.607, 29.589) then
openTween:Play()
else
closeTween:Play()
end
end)
Thanks in advance.