Cannot change text to IntValue (SOLVED)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the text auto-update to the IntValue value
  2. What is the issue? Include screenshots / videos if possible!
    It doesn’t work, the intvalue is decreased but the text doesn’t update
    image
    And theres no errors at all
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have read multiple topics about those things, nothing of them worked

This is the Self Updating Code
image

local Player = game.Players.LocalPlayer
local Label = game.StarterGui:WaitForChild("Stats").Health
local Value = Label.Value.Value

while true do
	Label.Text = tostring(Value)
	wait(0.1)
end

image

--Functions--
local Player = game.Players.LocalPlayer
local MainGui = game.StarterGui:WaitForChild("Stats")
local Overall = MainGui:WaitForChild("Overall")
local Health = MainGui:WaitForChild("Health")
local Sanity = MainGui:WaitForChild("Sanity")
local Timeout = 100
local SecondsElasped = 0
local Pills = game.Workspace:WaitForChild("Pills")
local Pill1 = Pills.Pill1
local Pill2 = Pills.Pill2
local Pill3 = Pills.Pill3
local Pill4 = Pills.Pill4
local Pill5 = Pills.Pill5
--Functions--

--Script--



Pill1.Pill1.MouseClick:Connect(function()
	if Health.Value.Value == 100 then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, EAT TOO MUCH PILLS.")
	else
		Health.Value.Value = Health.Value.Value + 10
	end
end)

Pill2.Pill2.MouseClick:Connect(function()
	if Sanity.Value.Value == 100 then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, EAT TOO MUCH.")
	else
		Sanity.Value.Value = Sanity.Value .Value + 10
	end
end)

Pill3.Pill3.MouseClick:Connect(function()
	if Health.Value.Value == 100 then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, EAT TOO MUCH PILLS.")
	else
		Health.Value.Value= Health.Value.Value + 10
	end
end)

Pill4.Pill4.MouseClick:Connect(function()
	if Sanity.Value.Value == 100 then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, EAT TOO MUCH.")
	else
		Sanity.Value.Value = Sanity.Value.Value + 10
	end
end)

Pill5.Pill5.MouseClick:Connect(function()
	if Sanity.Value.Value == 100 then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, EAT TOO MUCH.")
	else
		Sanity.Value.Value = Sanity.Value.Value + 10
	end
end)

while true do
	wait(0.5)
	if Sanity.Value.Value == 0 then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, 0 SANITY.")
	end
end

while true do
	wait(0.5)
	if Health.Value.Value == 0  then
		local dead = game.Lighting:WaitForChild("BlurE")
		dead.Size = 24
		wait(1)
		Player:Kick("YOU DIED, 0 HEALTH.")
	end
end

Im new to scripting, If I did something wrong on the topic please fix

local Player = game.Players.LocalPlayer
local Label = Player.PlayerGui:WaitForChild("Stats").Health
local Value = Label:WaitForChild("Value").Value

while true do
	Label.Text = tostring(Value)
	task.wait(.1)
end

When in-game, StarterGui becomes PlayerGui.

2 Likes

The value of Label should be Player.PlayerGui:WaitForChild(“Stats”).Health.

1 Like

never use wait() guys

while task.wait() do
	Label.Text = tostring(Value)
end
2 Likes

I know, I edited it. I didnt notice.

1 Like

What is the purpose of using a string for an IntValue?
A string is a bunch of numbers, spaces, or letters, like what you’d type in a chat in game.
An IntValue.Value is just a non-decimal number, or a ‘whole number’.
Are you trying to print the value in an output, like

print("D_devc has 39 stats points")
1 Like

Still doesn’t work, I’ll give the system code

--Functions--
local Player = game.Players.LocalPlayer
local MainGui = game.StarterGui:WaitForChild("Stats")
local Overall = MainGui:WaitForChild("Overall")
local Health = MainGui:WaitForChild("Health")
local Sanity = MainGui:WaitForChild("Sanity")
local Timeout = 100
local SecondsElasped = 0
local Pills = game.Workspace:WaitForChild("Pills")
local Pill1 = Pills.Pill1
local Pill2 = Pills.Pill2
local Pill3 = Pills.Pill3
local Pill4 = Pills.Pill4
local Pill5 = Pills.Pill5
local Alive = true
--Functions--

while Alive do
	Health.Value.Value = Health.Value.Value -1
	wait(1)
end

I am trying to change the text to a IntValue number

But it isn’t a text number, IntValue is already just a number.

1 Like

I want the number of this text to be as the same as IntValue

image
image

It’s not working because you’re only getting the Value once. Meaning that the Value retrieved will always remain the same regardless if it changes or not. I would recommend you updating it whenever the Value changes.

-- Services
local Players = game:GetService("Players")

-- Variables
local LocalPlayer = Players.LocalPlayer
local LocalPlayerGui = LocalPlayer:WaitForChild("PlayerGui", 60)

-- UIs
local Label = LocalPlayerGui:WaitForChild("Stats"):WaitForChild("Health")
local Value = Label:WaitForChild("Value")

-- Update
Value:GetPropertyChangedSignal("Value"):Connect(function()
	Label.Text = tostring(Value.Value)
end)
1 Like

So set the text property equal to the IntValue.Value

1 Like
--Functions--
local Player = game.Players.LocalPlayer
local MainGui = Player.PlayerGui:WaitForChild("Stats")
local Overall = MainGui:WaitForChild("Overall")
local Health = MainGui:WaitForChild("Health")
local Sanity = MainGui:WaitForChild("Sanity")
local Timeout = 100
local SecondsElasped = 0
local Pills = game.Workspace:WaitForChild("Pills")
local Pill1 = Pills.Pill1
local Pill2 = Pills.Pill2
local Pill3 = Pills.Pill3
local Pill4 = Pills.Pill4
local Pill5 = Pills.Pill5
local Alive = true
--Functions--

while task.wait() do
	Health["Value"].Value = -=1
end
1 Like

Thanks! It worked, now I need some help with decreasing the value number as it broken

oh yeah it should just be -=1 not = -=1

1 Like

Thanks to yall helping me :slight_smile: [][][][][][]

You want to change it whenever the Player’s Health goes down? Just use this to check it.

-- Services
local Players = game:GetService("Players")

-- Variables
local LocalPlayer = Players.LocalPlayer
local LocalCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local LocalHumanoid = LocalCharacter:WaitForChild("Humanoid")
local UpdateConnection = nil

-- UIs
local LocalPlayerGui = LocalPlayer:WaitForChild("PlayerGui", 60)
local Label = LocalPlayerGui:WaitForChild("Stats"):WaitForChild("Health")
local Value = Label:WaitForChild("Value")

-- Update Character and Humanoid
LocalPlayer:GetPropertyChangedSignal("Character"):Connect(function()
	LocalCharacter = LocalPlayer.Character
	LocalHumanoid = LocalCharacter:FindFirstChildWhichIsA("Humanoid")

	if UpdateConnection then
		UpdateConnection:Disconnect()
		UpdateConnection = nil
	end

	UpdateConnection = LocalHumanoid:GetPropertyChangedSignal("Health"):Connect(function()
		Value.Value = LocalHumanoid.Health
	end)
end)

-- Update Value Label
Value:GetPropertyChangedSignal("Value"):Connect(function()
	Label.Text = tostring(Value.Value)
end)

-- Update Player's Health
UpdateConnection = LocalHumanoid:GetPropertyChangedSignal("Health"):Connect(function()
	Value.Value = LocalHumanoid.Health
end)