Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script for Intvalue in textlabel, but doesnt work with no errors?

So, I'll just get right into it.

Script for leaderstats in ServerScriptService:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	if player then
		local folder = Instance.new('Folder')
		folder.Name = 'leaderstats'
		folder.Parent = player
		
		local coins = Instance.new('IntValue')
		coins.Name = 'Coins'
		coins.Parent = folder
		coins.Value = 0
		
		local rank = Instance.new('StringValue')
		rank.Name = 'Rank'
		rank.Parent = folder
		rank.Value = player:GetRoleInGroup(950346) --Used Frappé as an example as I don't have a group yet.
	end
end)

Script for the textlabel: (local script)

while wait() do
	local player = game.Players.LocalPlayer
	script.Parent.Text = ""..player:WaitForChild("leaderstats"):FindFirstChild("Coins").Value
end

I get no errors? Help would be apriciated.

1 answer

It appears you have done the local script incorrectly, replace the script with the following:

repeat wait(0) until player.leaderstats --yields the script until the leaderstats folder was created
repeat wait(0) until player.leaderstats.Coins --yields the script until the coin value was created
while wait() do
    local player = game.Players.LocalPlayer
    script.Parent.Text = tostring(player.leaderstats:FindFirstChild("Coins").Value)
end

3 comments

0

Still doesn't work!

0

Where are you putting the LocalScript?

0

In the textlabel

This discussion is preserved as it was. New answers, comments, and votes are closed.