You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? When pressing the Upgrade View Button, The text label changing at the same time
-
What is the issue? When pressing the button, it switches. One text label changes and the other doesn’t
-
What solutions have you tried so far? I tried switching the code but nothing works
Here are my latest attempts when trying to fix the problem
local upgradeView = false
function toggleTowerInfo()
workspace.Camera:ClearAllChildren()
gui.TowerBar.TowerLabel.Text = "TOWERS : "..placedTowers.." / "..maxTowers
if selectedTower then
CreateRangeCircle(selectedTower)
local config = selectedTower:WaitForChild("Config")
gui.SelectionFrame.Visible = true
gui.SelectionFrame.UpgradesHolder.RangeStats.RangeNumber.Text = config.Range.Value
gui.SelectionFrame.UpgradesHolder.DamageStats.DamageNumber.Text = config.Damage.Value
gui.SelectionFrame.UpgradesHolder.CooldownStats.CooldownNumber.Text = config.Cooldown.Value
gui.SelectionFrame.Options.Sell.SellBtn.Text = "$"..config.Sell.Value - (config.Sell.Value*0.1)
gui.SelectionFrame.OwnerName.Text = config.Owner.Value.."'s"
gui.SelectionFrame.TowerName.Text = config.OriginName.Value
gui.SelectionFrame.TargetSelection.TargetName.Text = config.TargetMode.Value
local modes = {
["First"] = Color3.new(1, 0, 0),
["Last"] = Color3.new(1, 1, 0),
["Nearest"] = Color3.new(0, 1, 0),
["Strongest"] = Color3.new(0.15, 0.15, 0.15),
["Weakest"] = Color3.new(1, 1, 1)
}
local color = modes[config.TargetMode.Value]
gui.SelectionFrame.TargetSelection.TargetName.TextColor3 = color
local towerViewModel
if replicatedStorage.Towers:FindFirstChild(selectedTower.Name) then
towerViewModel = replicatedStorage.Towers:FindFirstChild(selectedTower.Name):Clone()
else
towerViewModel = replicatedStorage.Towers.Upgrades:FindFirstChild(selectedTower.Name):Clone()
end
towerViewModel.Name = "Model"
if gui.SelectionFrame.ViewportFrame.WorldModel:FindFirstChild("Model") then
gui.SelectionFrame.ViewportFrame.WorldModel.Model:Destroy()
towerViewModel.Parent = gui.SelectionFrame.ViewportFrame.WorldModel
else
towerViewModel.Parent = gui.SelectionFrame.ViewportFrame.WorldModel
end
local camera = Instance.new("Camera")
camera.Name = "Camera"
camera.Parent = towerViewModel.Config
camera.CFrame = CFrame.new(towerViewModel.HumanoidRootPart.Position + (towerViewModel.HumanoidRootPart.CFrame.lookVector*3.5) + Vector3.new(-2.5,1.5,0), towerViewModel.HumanoidRootPart.Position)
gui.SelectionFrame.ViewportFrame.CurrentCamera = towerViewModel.Config.Camera
local towerViewTrack = towerViewModel.Humanoid:LoadAnimation(towerViewModel.AnimsFolder.Idle)
towerViewTrack.Looped = true
towerViewTrack:Play()
if config.Owner.Value == players.LocalPlayer.Name then
gui.SelectionFrame.Options.Visible = true
local upgradeTower = config:FindFirstChild("Upgrade")
if upgradeTower then
gui.SelectionFrame.Options.Upgrade.UpgradeBtn.Visible = true
gui.SelectionFrame.Options.Upgrade.UpgradeView.Visible = true
gui.SelectionFrame.UpgradesHolder.UpgradeName.Text = selectedTower.Config.Upgrade.Value.Name
gui.SelectionFrame.Options.Upgrade.UpgradeBtn.Text = "$"..upgradeTower.Value.Config.Price.Value
for i, v in pairs(selectedTower.Config.Upgrade.Value.Config:GetChildren()) do
if v.Name == "Range" or v.Name == "Damage" or v.Name == "Cooldown" then
if upgradeView == false then
upgradeView = true
if v.Value ~= selectedTower.Config[v.Name].Value then
gui.SelectionFrame.UpgradesHolder[v.Name.."Stats"][v.Name.."Number"].Text = selectedTower.Config[v.Name].Value.." -> "..v.Value
else
gui.SelectionFrame.UpgradesHolder[v.Name.."Stats"][v.Name.."Number"].Text = selectedTower.Config[v.Name].Value
end
else
upgradeView = false
gui.SelectionFrame.UpgradesHolder[v.Name.."Stats"][v.Name.."Number"].Text = selectedTower.Config[v.Name].Value
end
end
end
else
gui.SelectionFrame.UpgradesHolder.UpgradeName.Text = "Maxed Upgrades"
gui.SelectionFrame.Options.Upgrade.UpgradeBtn.Visible = false
gui.SelectionFrame.Options.Upgrade.UpgradeView.Visible = false
end
else
gui.SelectionFrame.Options.Visible = false
end
else
gui.SelectionFrame.Visible = false
end
end
gui.SelectionFrame.Options.Upgrade.UpgradeView.Activated:Connect(function()
if selectedTower then
if upgradeView == false then
toggleTowerInfo()
else
toggleTowerInfo()
end
end
end)
If you need more description here is the video
robloxapp-20240604-1936546.wmv (5.1 MB)
I want my upgrade view is just like the Bacon Slasher and not the Noob Guuner
Thx For Reading :3