Ad
Log in to vote
0

towers arent spawning in tower defence game im making. whats going on?

Asked by 11 days ago

making a tower defence game, im pressing a button that places a tower but nothing spawns, and nothing happens at all, and theres no errors, this happened after i added some functions that check if the tower is able to be spawned or not. Module script:

function Tower.Spawn(player, name, cframe)
  local allowedToSpawn = Tower.CheckPermission(player, name)
    if allowedToSpawn then

        local newTower = replicatedStorage.Towers[name]:Clone()
        newTower:SetPrimaryPartCFrame(cframe)
        newTower.Parent = workspace.Towers

        local CFrame = Instance.new("CFrameValue")
        CFrame = Vector3.new(math.huge, math.huge, math.huge)
        CFrame = newTower.HumanoidRootPart.CFrame
        for i, object in ipairs(newTower:GetDescendants()) do
            if object:IsA("BasePart") then
                PhysicsService:SetPartCollisionGroup(object, "Tower")
            end
        end
        player.Money.Value -= newTower.Config.Price.Value
        player.PlacedTowers.Value += 1
        coroutine.wrap(Tower.Attack)(newTower, player)
    else
        warn("REQUESTED TOWER DOES NOT EXIST", name)
    end
end
function Tower.CheckPermission(player, name)
    local towerExists = replicatedStorage.Towers:FindFirstChild(name)

    if towerExists then
        if towerExists.Config.Price.Value <= player.Money.Value then
            if player.PlacedTowers.Value < 25 then
                return true
            else
                warn("MAX TOWERS")
            end
            else warn("CANNOT AFFORD TOWER")
        end
    else
        warn("TOWER DOES NOT EXIST")
    end
    return false
end
RequestTower.OnServerInvoke = Tower.CheckSpawn

local script:

for i, tower in pairs(towers:GetChildren()) do
    local button = gui.Towers.Template:Clone()
    local config = tower:WaitForChild("Config")
    button.Name = tower.Name
    button.Parent = gui.Towers
    button.Visible = true
    button.Text = tower.Name
    button.Price.Text = config.Price.Value
    button.Activated:Connect(function()
        print("1")
        local allowedToSpawn = RequestTower:InvokeServer(tower.Name)
        if allowedToSpawn then
            AddTower(tower.Name)
        end
    end)
end
0
It’s you from the discord right? Puppynniko 983 — 11d
0
Place the check permission to the top Puppynniko 983 — 11d
0
And where’s checkspawn Puppynniko 983 — 11d

Answer this question