I’m making a placement system for a Tower Defense game I am creating, I am trying to stop the towers from being placed on the path. This works, however, in each tower there is a transparent part that shows their range. Because of this, the tower can be placed on top of the path because the mouse.Target is touching the invisible range part.
I am unable to use mouse.TargetFilter, because I am already using it to filter out the tower I am placing.
-- Local Script
local tower = Tower:Clone()
tower.Parent = workspace
local placed = false
mouse.TargetFilter = tower -- filtering out the tower being placed
repeat
tower:MoveTo(mouse.Hit.p)
tower:FindFirstChildWhichIsA("Tool").Handle.Anchored = true
mouse.Button1Down:Connect(function()
if mouse.Target.Parent ~= workspace.Paths and mouse.Target.Parent ~= workspace.Waypoints then -- stopping the tower from being placed on the path
placed = true
end
end)
wait()
until placed == true
print(mouse.Target) -- still places because mouse.Target is the Range Part of other towers
tower:Destroy()
game.ReplicatedStorage.Events.PlaceTower:FireServer(Tower, mouse.Hit.p, cost) -- placing tower on server
Any help is appreciated, if I am doing something that should be changed please let me know. Many Thanks.