Pop-up info on item. Best Way to execute it?

This may be a long thread/topic but I want to write as much as I can so you can understand it. So I am working on a RPG Game, similar to Dungeon Quest and Adventure Up So from my other topics I talk about trying to learn Datastores, and I’m struggling, but this isn’t about that. So I have a Weapon, Potions and Armour folder in ReplicatedFirst. So what I want to do is when a player unlocks the weapons it adds it to the inventory, I have a system where it goes through the folder and checks if players owned Value is true then it will give item, and when it is in the inventory I want it so when my mouse goes over that item, it will display the name of weapon, the rarity, the damage, magic damage and health. I have 2 ideas.

  1. In my weapon I create a value with name, health, damage, rarity and magic damage and when a player hovers over the item it will go into the viewportFrame and get the details and display them. Since the viewport will have a clone of the weapon. Now this way has it’s Pro’s and Con’s and the one con is that it is time consuming putting each value everytime a weapon is made. This is just a quick rough idea of what it could possibly look like.

    --// Variables
    local Item = [ViewportFrame location] -- ViewportFrame
    local Dmg = item.[Model].Damage.Value -- Model being the weapon or armour
    local Health = item.[Model].Health.Value
    local magicDmg = item.[Model].["Magic Damage"].Value
    local name = item.[Model].Name.Value
    local Rarity = item.[Model].Rarity.Value
    local display = script.Display -- Displays location
    
    --// Mouse Actions
    item.MouseHover:Connect(function() -- When mouse hover
         display.Visible = true -- Previously set to false
         dmgText = display.Damage.Value
         -- So on for all of them
    end)
    
    item.MouseLeave:Connect(function()
         display.Visible = false
    end)
    
  2. Checks a table with the data which is in the datastore and it will get the value of that weapon and set each value to the weapons damage, health, name etc Value.
    So for this is one I’m not sure on how to do it, because I have to access a table and I’m not good with tables but;

    --// Varaibles
    
    local Table = require(Location_of_Module_Script) -- I have a module script which has a table with serial numbers for each weapon.
    local Serial = [ViewportFrame location].NAME_OF_MODEL.Serial.Value -- ViewportFrame
    local display = script.Display -- Displays location
    local TableTable = Table.TableList -- TableList is what the table is called
    
    
    --// Mouse Actions
    item.MouseHover:Connect(function()
        display.Visible = true -- Previously set to false
        display.Damage.Value = TableTable[Serial]["Damage"]
        display.Health.Value = TableTable[Serial]["Health"] -- Not sure how to access the values.
        -- So on
    end)
    
    item.MouseLeave:Connect(function()
         display.Visible = false
    end)
    

    Module Script:

    --// Table inside Module Script 
       [1] = {
           ["Name"] = "Wooden Sword",
           ["Owned"] = true,
           ["Damage"] = 5,
           ["Magic Damage"] = 2,
           ["Health"] = 0, 
           ["Rarity"] = "Common"
        }
    

Now there may be easier way that I’m not aware of, please inform me if so. Which one would be the best way to execute this, my explanations may not be the best but if you need further info please feel free to ask. Any Help is Appreciated.

Well have you tried either of the methods youve just presented?

Well not really, I wrote this and had to go so I didn’t to try them, I also have to make the PopUpUI and make a sword, this was what I the idea I had at the time, I just want to know what is the best way to approach it is. I will definitely try this tomorrow.

1 Like