since nobody answered my question about how to make a placement system ( How to make a placement system for tower defense? - Help and Feedback / Scripting Support - DevForum | Roblox), i used my old one, it works fine, but it can only filter one thing, btw this is temporary, it obviously wont be in the game, anyways, when i place the tower, it spams: attempt to index nil with transparency.
code:
local tower = game.ReplicatedStorage.Towers.GroundTower
local TowerType = "Ground"
local button = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local placeTypes = game.Workspace.PlaceTypes
local uis = game:GetService("UserInputService")
local placing = false
local invis = nil
function createInvis()
local Tower = tower:Clone()
Tower.Transparency = .5
mouse.TargetFilter = Tower
Tower.Parent = workspace
Tower.Position = mouse.hit.p + Vector3.new(0,tower.Size.Y/2,0)
return Tower
end
button.Activated:Connect(function()
placing = true
if invis == nil then
invis = createInvis()
end
end)
mouse.Move:Connect(function()
print(invis)
if placing == false or invis == nil then return end
invis.Position = mouse.hit.p + Vector3.new(0,tower.Size.Y/2,0)
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if mouse.Target.Parent == game.Workspace.floorpath then
elseif mouse.Target.Parent == placeTypes.Ignore then
elseif mouse.Target.Parent == placeTypes.Cliff then
if TowerType == "Cliff" then
invis.Transparency = 0
invis = nil
placing = false
end
else
if TowerType == "Ground" then
invis.Transparency = 0
invis = nil
placing = false
end
end
end
if input.KeyCode == Enum.KeyCode.Q then
placing = false
end
end)
end)