You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want the text auto-update to the IntValue value
What is the issue? Include screenshots / videos if possible!
It doesn’t work, the intvalue is decreased but the text doesn’t update
And theres no errors at all
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
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
--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
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
--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
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)
--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