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)```
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.
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
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