i want to link textlabel of currency with player leaderstats i have tried tonumber() and tostring()
but they are not the right ones to use
1 Like
Can you show us your script, please?
1 Like
local TextLabel = script.Parent
local Stat = game:GetService("Players").LocalPlayer.leaderstats.yourstat
local Update = function()
TextLabel.Text = tostring(Stat.Value)
end
Update()
Stat.Changed:Connect(Update)
1 Like
-- In ServerScriptService, create a script named "LeaderstatsScript"
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0 -- Initial points value
points.Parent = leaderstats
end)
1 Like
-- In StarterPlayerScripts, create a LocalScript named "UpdateGuiScript"
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local points = leaderstats:WaitForChild("Points")
local screenGui = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
local textLabel = screenGui:WaitForChild("TextLabel")
local function updateText()
textLabel.Text = "Points: " .. points.Value
end
points.Changed:Connect(updateText)
-- Initial update
updateText()
2 Likes
deleted the lines cuz they give me errors
What is happened you are get error game Maybe screenshot send me
Thats not how that works buddy, leaderstats isnβt located in game.Players
lol forgot localplayerβ β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
ik i fixed it myself but thank you ![]()
found the solution but thanks ![]()
You are help Enjoy Game Nice day
Nice day for you all and thank you so much ![]()
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.