So, I'm trying to make a tycoon game where I can place down objects wherever I want. I don't want the mouse to target the preview model, and how would I go about doing that? This is what I have so far, and the Target Filter I'm trying to use is in there.
01 | while wait() do |
02 | mouse.TargetFilter = (prevmodel) |
03 | local filter = mouse.TargetFilter(prevmodel) |
04 | if mouse.Target ~ = nil then |
05 | if mouse.Target.Parent.Name = = "Model" then |
06 | else |
07 | prevmodel:MoveTo(Vector 3. new((math.floor(mouse.hit.p.X) +offset),(math.floor(mouse.hit.p.Y) +offset),(math.floor(mouse.hit.p.Z) +offset))) |
08 | end |
09 | end |
10 | if script.TurnOff.Value = = true then |
11 | prevmodel:Remove() |
12 | script.TurnOff.Value = false |
13 | script.Disabled = true |
14 | end |
15 | end |
when using the mouse.Target, it doesn't target models, so an easy fix is to set the TargetFilter to a part around the model. This part's name is hitbox and would inside the model, anchored,fully transparent, and CanCollide is false. Now with the hitbox position/size it so it's surrounding the model, then set TargetFilter to this part:
1 | mouse.TargetFilter = prevmodel.hitbox |