J0shuva
(joshua)
#1
I am currently trying to display a notification on screen whenever a Stat value is changed, although I am having problems doing so.
game.Players.LocalPlayer.Stats.NPC.Changed:Connect(function()
print("Changed")
local tl = Instance.new("TextLabel")
tl.Parent = Player.PlayerGui.NOTIFICATIONBOX.Frame
tl.BackgroundTransparency = 1
tl.TextColor3 = Color3.new(1, 1, 1)
tl.Size = UDim2.new(1,0,0.245,0)
tl.TextScaled = true
tl.Font = "Ubuntu"
tl.Text = "Succesfully served customer (+1)"
I am not getting any errors when the NPC value is changed and nothing is being printed, I have also already tried:
game.Players.LocalPlayer.Stats.NPC.Value.Changed:Connect(function()
Although that is also not working, any ideas?
2 Likes
frriend
(Neohertz)
#2
You need to detect the change of the object itself, not its value.
Try game.Players.LocalPlayer.Stats.Changed:Connect(function()
instead.
J0shuva
(joshua)
#3
That is not working for some reason, The folder is Stats and the value is NPC if that helps.
2 Likes
Abcreator
(Abcreator)
#4
Is this a localscript or a server script?
frriend
(Neohertz)
#5
Oops typo! I meant game.Players.LocalPlayer.Stats.NPC.Changed:Connect(function()
! My apologies.
Abcreator
(Abcreator)
#6
He has already tried doing that.
1 Like
Abcreator
(Abcreator)
#8
Is there anything before that part of the script?
frriend
(Neohertz)
#9
Brainfart, my bad. Been bouncing between threads.
1 Like
J0shuva
(joshua)
#10
Just this:
local Player = game.Players.LocalPlayer
maybe try it like this:
local Player = game:GetService(“Players”).LocalPlayer
local StatsFolder = Player:WaitForChild(“Stats”)
local NPC = StatsFolder.NPC
NPC.Changed:Connect(function()
print(“Changed”)
local tl = Instance.new(“TextLabel”)
tl.Parent = Player.PlayerGui.NOTIFICATIONBOX.Frame
tl.BackgroundTransparency = 1
tl.TextColor3 = Color3.new(1, 1, 1)
tl.Size = UDim2.new(1,0,0.245,0)
tl.TextScaled = true
tl.Font = “Ubuntu”
tl.Text = “Succesfully served customer (+1)”
end)
Abcreator
(Abcreator)
#12
Are you missing your
end)
Or did you just forget to copy it to the code above?
Abcreator
(Abcreator)
#13
Here is a formatted version of that code:
1 Like
How is the NPC
stat being changed? Maybe whatever is responsible for changing the stat isn’t doing its job.
1 Like
Abcreator
(Abcreator)
#15
Are you getting errors when you start the game?
J0shuva
(joshua)
#16
It is changing the value, I have the Value open while I’m testing.
1 Like
J0shuva
(joshua)
#17
No, nor did that other code suggested work.
Abcreator
(Abcreator)
#18
So it is the Value your changing and not the name.
That doesnt make sense, are you sure that is the right place of the value and is it really getting changed?
and do you really get no errors?
1 Like
J0shuva
(joshua)
#20
Yeah I’m trying to get it to send a notification once the value is changed.