ItsDontM
(Java_cup)
January 3, 2022, 7:34am
#1
Hello! This is a local script in a text button whose purpose is to add one to Value each time the button is pressed.
local Point = Instance.new("IntValue")
Point.Name ="Point"
Point.Value = 0
Point.Parent = script.Parent
script.Parent.MouseButton1Click:Connect(function()
game.StarterGui.ScreenGui.Change.Text = Point.Value + 1
print("text")
end)
But the points are not added and the number does not change. Zero left.
Bye!
1 Like
RoBoPoJu
(RoBoPoJu)
January 3, 2022, 7:41am
#2
Your code does not change Point.Value
. If it’s supposed to increase, you should add Point.Value += 1
, which s the same as Point.Value = Point.Value + 1
, and also remove the + 1 from the next line.
local Point = Instance.new("IntValue")
Point.Name ="Point"
Point.Value = 0
Point.Parent = script.Parent
script.Parent.MouseButton1Click:Connect(function()
Point.Value += 1
game.StarterGui.ScreenGui.Change.Text = Point.Value
print("text")
end)
Edit: I didn’t notice the startergui problem that is mentioned in the replies below. @Spellwastaken posted code that may work.
Please always check if its
game.StarterGui.....
This does not change on any GUI, instead
to singleplayer
script.Change.Text = Point.Value + 1
to everyone
-- Ye u need an event for this. the materials are 1 local script, 1 normal script, and 1 event thing
The game.StarterGui
has been created many times (too much topic created because of it)
ItsDontM
(Java_cup)
January 3, 2022, 7:53am
#4
The script still doesn’t work.
local Point = Instance.new("IntValue")
Point.Name ="Point"
Point.Value = 0
Point.Parent = script.Parent
script.Parent.MouseButton1Click:Connect(function()
Point.Value += 1
game.Players.LocalPlayer.PlayerGui.ScreenGui.Change.Text =tostring( Point.Value )
print("text")
end)
If it worked please set it as the solution thanks!
puofz
(puofz)
January 3, 2022, 8:01am
#6
i dont see any errors but im so confused where the script parent is parented to
bc if im not wrong the buttton is screen ui and you requested startergui service again?
ItsDontM
(Java_cup)
January 3, 2022, 8:02am
#7
When you press it, it writes 1, when you press it one more time, the number one remains.
Try it out man if it worked please set it as the solution thank you so much !
1 Like
ItsDontM
(Java_cup)
January 3, 2022, 8:04am
#9
you mean that startergui dont need?
puofz
(puofz)
January 3, 2022, 8:07am
#10
is this what your starter gui explorer look like?
1 Like
puofz
(puofz)
January 3, 2022, 8:12am
#11
yes because ur uis will go in da player’s uis called PlayerGui
1 Like
i just edited it try it again now thanks!