Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to cheek that a the part clicked have the name Cartridges?

Asked by 6 years ago

How would you go about to make it only for parts that have the name Cartridges

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03local down
04local mtarget
05 
06function clickObj()
07    if mouse.Target ~= nil then
08        mtarget = mouse.Target
09        print(mtarget)
10        down = true
11        mouse.TargetFilter = mtarget
12        print(mouse.TargetFilter)
13    end
14end
15mouse.Button1Down:connect(clickObj)
View all 32 lines...
0
if mouse.Target.Name == "Cartridges" then --code end   -- thank me later piRadians 297 — 6y

1 answer

Log in to vote
0
Answered by
juel90 26
6 years ago
Edited 6 years ago

The Mouse.TargetFilter part was useless you can just do Mouse.Target.Name so your code should now be this.

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03local down
04local mtarget
05 
06function clickObj()
07    if mouse.Target ~= nil and mouse.Target.Name == "Cartridge" then
08        mtarget = mouse.Target.Name
09        print(mtarget)
10        down = true
11    end
12end
13mouse.Button1Down:connect(clickObj)
14 
15function mouseMove()
View all 29 lines...
Ad

Answer this question