Sword Tier Upgrading Problem

Hello. I’m trying to make a sword game with a upgraded Tier system for tools. I’m facing a few problems one being where it duplicates the sword and doesn’t destroy it [replace it] and the second you can keep upgrading it by buying the same sword but I want the progression to go to a 5 star like system. and the Tier 2 icon doesn’t work it just disappears. [I’m not sure if its because the image is new or if its the code]

SERVERSCRIPTSERVICE CODE:

local ServerStorage = game:GetService("ServerStorage")

local upgradeEvent = ReplicatedStorage:WaitForChild("RequestSwordUpgrade")
local updateGUIEvent = ReplicatedStorage:WaitForChild("UpdateSwordGUI")

local tieredSwordsFolder = ServerStorage:WaitForChild("TieredSwords")
local upgradeCost = 100

upgradeEvent.OnServerEvent:Connect(function(player)
	local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
	local backpack = player:FindFirstChild("Backpack")
	local character = player.Character

	if cash.Value < upgradeCost then
		warn("Not enough cash")
		return
	end

	-- Find existing sword in Backpack or Character
	local currentSword = backpack:FindFirstChild("SanctumVendetta") or (character and character:FindFirstChild("SanctumVendetta"))

	if currentSword then
		currentSword:Destroy()
	end

	-- Get new upgraded sword from ServerStorage
	local newSword = tieredSwordsFolder:FindFirstChild("Tier2Sword") -- adjust to your sword names!
	if not newSword then
		warn("Upgraded sword not found in TieredSwords folder")
		return
	end

	cash.Value -= upgradeCost

	-- Clone and put new sword
	local clone = newSword:Clone()
	clone.Parent = backpack

	-- Example: determine the tier for GUI update
	local tier = 2
	updateGUIEvent:FireClient(player, tier)
end)

Local Script for the button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local mainGui = playerGui:WaitForChild("MainGui")
local swordUpgradeFrame = mainGui:WaitForChild("SwordUpgradeFrame1")
local backgroundFrame = swordUpgradeFrame:WaitForChild("BackgroundUpgrade1")

local upgradeButton = backgroundFrame:WaitForChild("UpgradeButton1")
local tierImage = backgroundFrame:WaitForChild("TierGoldenStars1")
local tierTextLabel = backgroundFrame:WaitForChild("TierTextLabel1")
local ldLabel = backgroundFrame:WaitForChild("LDTxtLabel1")
local sdLabel = backgroundFrame:WaitForChild("SDTxtLabel1")
local bdLabel = backgroundFrame:WaitForChild("BDTxtLabel1")

local upgradeEvent = ReplicatedStorage:WaitForChild("RequestSwordUpgrade")
local updateGUIEvent = ReplicatedStorage:WaitForChild("UpdateSwordGUI")

upgradeButton.MouseButton1Click:Connect(function()
	upgradeEvent:FireServer()
end)

updateGUIEvent.OnClientEvent:Connect(function(tier)
	tierTextLabel.Text = "Tier " .. tier .. " Stats:"

	if tier == 2 then
		tierImage.Image = "rbxassetid://121730569024201"
		tierImage.Visible = true
		ldLabel.Text = "45"
		sdLabel.Text = "20"
		bdLabel.Text = "15"
	elseif tier == 3 then
		tierImage.Image = "rbxassetid://YOUR_TIER3_IMAGE_ID"
		tierImage.Visible = true
		ldLabel.Text = "60"
		sdLabel.Text = "35"
		bdLabel.Text = "25"
	else
		tierImage.Image = "rbxassetid://DEFAULT_IMAGE_ID"
		tierImage.Visible = true
		ldLabel.Text = "-"
		sdLabel.Text = "-"
		bdLabel.Text = "-"
	end
end)```
2 Likes

Hello. Could you first check that there is no misspellings.

I recommend you add a print() here so you make sure the script found the tool.

Also, could you clarify what is the desired outcome for this:

Does the upgrading stop at tier 5?
What do you mean by “5 star like system”?

1 Like

Hello, when i say “5 Star like system” I plan to have it where you press the upgrade once it fills in a image, which is the star representation when it gets max of 5 golden starts it will change to a blue like rarity.

If I am understanding correctly, the way you could do that is by keeping track of two values:

  • Tier (e.g Tier 1, Tier 2)
  • Stars (e.g 5 stars)

Whenever the sword gets upgraded you:

  • Incriment the amount of stars
  • Check if the amount of stars exceed 5 and then if it does you upgrade the tier
1 Like

Hello there, I was able to fix it but im facing a problem. When I do upgrade I am unable to display the image properly it just goes invisible. Im not sure whats going wrong

local tierStats = {
	[1] = {tierText = "Tier 1 Stats:", ld = "30", sd = "10", bd = "5", cashPerKill = "+100", imageId = "rbxassetid://121730569024201"}
	[2] = {tierText = "Tier 2 Stats:", ld = "45", sd = "20", bd = "15", cashPerKill = "+500", imageId = "rbxassetid://121730569024201"},
	[3] = {tierText = "Tier 3 Stats:", ld = "60", sd = "30", bd = "25", cashPerKill = "+1000", imageId = "rbxassetid://121730569024201"},
	[4] = {tierText = "Tier 4 Stats:", ld = "80", sd = "50", bd = "40", cashPerKill = "+2000", imageId = "rbxassetid://121730569024201"},
	[5] = {tierText = "Tier 5 Stats:", ld = "120", sd = "70", bd = "60", cashPerKill = "+5000", imageId = "rbxassetid://121730569024201"},```

Hello. Make sure to try these things out:

  • Does the image work if you try to show it manually (not in a script)
  • Are you applying the imageId to the right element.

Also I tried to use your imageId myself and it converted into

rbxassetid://100098234495883
1 Like

It works when I manually do it, The imageId does change to the next one up 121730569024201 but roblox just doesnt display it

The must be something wrong with the Id then. Try changing it to this:

1 Like

image
this is what displays in the dev console

Make sure there is a comma at the end of each table element like you see here:

local tbl = {1, 2, 3}

even when solving that it still makes the ImageID invisible

Could you send me the table again. And make sure that the ImageTransparency on the tierImage is set to 0.

sorry for the long reply I was trying to make it display and now its ended up breaking the system completely.

Try undoing with Control + Z and paste this into your data:

local tierStats = {
	[1] = {tierText = "Tier 1 Stats:", ld = "30", sd = "10", bd = "5", cashPerKill = "+100", imageId = "rbxassetid://100098234495883"}
	[2] = {tierText = "Tier 2 Stats:", ld = "45", sd = "20", bd = "15", cashPerKill = "+500", imageId = "rbxassetid://100098234495883"},
	[3] = {tierText = "Tier 3 Stats:", ld = "60", sd = "30", bd = "25", cashPerKill = "+1000", imageId = "rbxassetid://100098234495883"},
	[4] = {tierText = "Tier 4 Stats:", ld = "80", sd = "50", bd = "40", cashPerKill = "+2000", imageId = "rbxassetid://100098234495883"},
	[5] = {tierText = "Tier 5 Stats:", ld = "120", sd = "70", bd = "60", cashPerKill = "+5000", imageId = "rbxassetid://100098234495883"},
}

And if this doesn’t work try re-uploading the image and using a new imageId.

1 Like

I mostly got it running, [Not the Image] it just keeps taking me from tier 1 to tier 3 and everything I’ve done hasn’t worked I don’t get it

Ah. I’m unable to help better remotely, but I hope you find a solution.

1 Like

I was able to fix the tier system, I am going to have to dive in deep on the imagery, it doesn’t make sense to me it sometimes appears in certain parts and others not. when you reach the max (3 for now) it shows a image but during the rest of it there is no image