Thanks for reading,
Okay I Know title is confusing. but I will try my best to explain in a good way
so I am trying to update gui everytime a player’s value changed
--This is a local script to send value and fire ValueChanged function
LocalPlayer.leaderstats.Strength.Changed:Connect(function(Wakanda)
AchivementModuleV2.ValueChanged("Strength",LocalPlayer.leaderstats.Strength.Value)
print(Wakanda)
end)
but I am consufed about how to reach the module that hold rewards,names etc just for that spesific Value’s part and update it because Value.Changed event only sends the newValue and I think I can’t just do it with sending “Strength” or “Coins” because I can’t use the max valuable since ı want the Value/max to stay there
like if it is strength value then I just want it use variables of totalStrength1 or 2
if sended value is 10 then for totalStrength 1 it should Change text to 10/20(max)
or for totalStrength2 it should Change text to 10/67890
local module = {
{ID = "TotalCoins1",Level= 1,Max = 100,Reward = "%10+Coins",Image = "rbxassetid://9310206048",},
{ID = "TotalStrength1",Level = 1,Max = 20,Reward= "%10+PowerPerSwing",Image = "rbxassetid://9310206048"},
-- {ID = "TotalSwingTime1",Level = 1,Max = 10,Reward= "FasterSwing",Image = "rbxassetid://9310206048"},
{ID = "TotalCoins2",Level= 2,Max = 56789,Reward = "%10+Coins",Image = "rbxassetid://12583460061"},
{ID = "TotalStrength2",Level = 2,Max = 67890,Reward= "%10+PowerPerSwing",Image = "rbxassetid://12583460061"},
--{ID = "TotalSwingTime2",Level = 2,Max = 100,Reward= "FasterSwing",Image = "rbxassetid://12583460061"}
}
return module
-- This is a module script
local ClickedItem
local MainFrame = script.Parent:WaitForChild("Frame")
local AchivementModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Achivements"))
local LocalPlayer = game:GetService("Players").LocalPlayer
local Template = script:WaitForChild("Template")
local ScrollingFrame = MainFrame:WaitForChild("Frame"):WaitForChild("ScrollingFrame")
local InfoFrame = MainFrame:WaitForChild("InfoFrame")
local InfoGoing = InfoFrame:WaitForChild("Going")
local InfoTakeIt = InfoFrame:WaitForChild("TakeIt")
local InfoReward = InfoFrame:WaitForChild("Reward")
local InfoFrameFrame = InfoFrame:WaitForChild("Frame")
local InfoProgressBar = InfoFrame:WaitForChild("ProgressBar")
local AchivementRemotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("AchivementModules")
local ClickedAchivements
local Achivement = {}
Achivement.__index = Achivement
local function ShowInfos(Visible)
InfoGoing.Visible = Visible
InfoReward.Visible = Visible
InfoTakeIt.Visible = Visible
InfoFrameFrame.Visible = Visible
end
function Achivement:ValueChanged(Number)
print("I am KindaBored")
print(Number)
if InfoReward.Text:find("Power") then
InfoGoing.Text = Number
end
end
function Achivement:Santarantiano() -- function to create buttons
print("TESTSTUFF")
ShowInfos(false)
print(AchivementModule)
for i, v in ipairs(AchivementModule) do
local object = setmetatable({},Achivement)
object.Name = if v.ID then v.ID else nil
object.Image = if v.Image then v.Image else nil
object.Level = if v.Level then v.Level else nil
object.Max = if v.Max then v.Max else nil
object.Reward = if v.Reward then v.Reward else nil
local TemplateClone = Template:Clone()
TemplateClone.Name = v.ID
TemplateClone.Parent = ScrollingFrame
TemplateClone.Visible = true
TemplateClone:WaitForChild("AchivementImage").Image = v.Image
TemplateClone.Activated:Connect(function()
print(object)
Achivement:OnClick(object)
print("ButtonTouched")
print(v)
end)
object.ClaimButton = InfoTakeIt
if v.Level == 1 then
TemplateClone.BackgroundColor3 = Color3.fromRGB(40, 65, 223)
elseif v.Level == 2 then
TemplateClone.BackgroundColor3 = Color3.fromRGB(209, 102, 223)
end
end
end
return Achivement
this is how it looks in game after client activated one of the buttons
(Don’t mind the shenhe pictures they are just random picture Id’s I found in toolbox)