Hello.
I am currently working on a wiring system.
If buildmode is on and you click the Left mouse button it places a part in a folder called Wire. Then inside that wire it adds an attachment called First.
Then when you click somewhere else it creates another attachment called Second, then it creates a RodConstraint that is between the 2 attachments.
But I want to make a system where you can destroy those constraints (aka “Wires”)
I want the RodConstraint to change thickness and color whenever a player hovers over it with a mouse, and change back when you dont hover, but I dont know how to make it able to detect that.
It works like this right now:
Mouse.Move:Connect(function()
if DestroyMode and not BuildMode then
for _,wire in pairs(workspace.WireSystem:GetChildren()) do
for _,attachment in pairs(wire:GetChildren()) do
if attachment:IsA("RodConstraint") then
attachment.Thickness = 0.15
end
end
end
end
end)
How would I detect that a player’s mouse hovers over the Rod constraint, as I can not find a event in the roblox developer wiki.
Thanks in advance,
Edit: Solved! I overcomplicated things.
My answer if you want it:
Instead of using Mouse.Move and do for loops to find each rod constraint, I added a part called HoverPart inside of the Wire with the size and position of the Rod Constraint.
Then I did checked Mouse.Target when the mouse moves and checked if they hovered over a part called HoverPart, if so then it does the actions.
Script:
Mouse.Move:Connect(function()
if DestroyMode and not BuildMode then
local Target = Mouse.Target
print(Target)
if Target then
if Target.Name == "HoverPart" then
Target.Parent.RodConstraint.Thickness = 0.18
Target.Parent.RodConstraint.Color = BrickColor.new("Cocoa")
latestRod = Target.Parent.RodConstraint
else
if latestRod ~= nil then
latestRod.Thickness = 0.1
latestRod.Color = BrickColor.new("Dusty Rose")
latestRod = nil
end
end
end
end
end)