Hello! This is my first question so point out anything I'm doing wrong.
I am attempting to make a game similar to Tower Defense Simulator. This is what I have for the tower placement script
LocalScript (in StarterGui)
-- Highlight Script --
-- Variables
local player = game.Players.LocalPlayer
local event = game.ReplicatedStorage.Remotes:WaitForChild('PlaceTower')
local button = script.Parent
local Highlight = game.Workspace.Highlight
local UIS = game:GetService('UserInputService')
local using = nil
local debounce = true
Highlight.Parent = nil
-- Setting and Configuring the Mouse
local mouse = player:GetMouse()
mouse.TargetFilter = Highlight
-- Place Function
local function place ()
local clicked
Highlight.Parent = game.Workspace
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and using then
print('called')
clicked = true
-- Getting and Sending CFrame
local HumanoidCFrame = Highlight:FindFirstChild('HumanoidRootPart').CFrame
event:FireServer(HumanoidCFrame, 'Tower1')
-- End
Highlight.Parent = nil
end
end)
while not clicked do
wait()
Highlight.HumanoidRootPart.CFrame = CFrame.new(mouse.Hit.p.X, mouse.Hit.p.Y + 1.315, mouse.Hit.p.Z)
end
end
-- Button Detection
button.MouseButton1Up:Connect(function()
using = true
place()
using = false
end)
Normal Script (in server script service)
-- Event Handlling Script --
-- ReplicatedStorage and Remotes
local ReplicatedStorage = game.ReplicatedStorage
local placeTower = ReplicatedStorage.Remotes:WaitForChild('PlaceTower')
-- Functions
local function placeTowerFunction(plr, cframe, tower)
print('Placed tower')
local Tower = ReplicatedStorage:WaitForChild(tower)
local TowerClone = Tower:Clone()
TowerClone.Parent = game.Workspace
TowerClone.HumanoidRootPart.CFrame = cframe
end
-- Activate
placeTower.OnServerEvent:Connect(placeTowerFunction)
Basically, I would place one tower, and one tower would place. After that, I would place a second tower and two towers would place in the same spot, then 3, 4, and so on.
I would really appreciate any help, Thanks!

2 comments
Oh my lord thank you so much!!
np