Editing a PlayerGui when an object is clicked

Hi again everyone

I’m making a system so that when a sphere is clicked, it will add one to the Player’s count, both on the leaderboard and on their personal ScreenGui count. The code I have made updates the Frame from “nil” to zero, but after that does not correspond with the value located in the “leaderstats” folder that is made under the LocalPlayer.

My format:

My current code: (localscript)

game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("kabob").Frame.TextLabel.Text = game.Players.LocalPlayer.leaderstats.kabobs.Value

Thanks everyone

Your current code only checks once, you’ll need to continually check the value.

This will update the Text whenever the leaderstat is changed.

local player = game.Players.LocalPlayer
local kabobs = player:WaitForChild("leaderstats").kabobs -- the stat

kabobs.Changed:Connect(function(value) -- value is the Value of the stat. You can change the variable to whatever name you want it to be, I used "value" for this example.
print(value, "kabobs")
player:WaitForChild("PlayerGui"):WaitForChild("kabob").Frame.TextLabel.Text = tostring(value)
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.