local plr = game.Players.LocalPlayer
local cookies = game:GetService("StarterGui")["Cookies/CPS"].Frame.Cookies.text
Humanoid = game.Workspace:WaitForChild(plr.Name)
Part = Instance.new("BillboardGui",Humanoid.Head)
Text = Instance.new("TextLabel",Part)
Part.ExtentsOffset = Vector3.new(0,3,0)
Part.Size = UDim2.new(1,1,1,1)
Text.Size = UDim2.new(5,0,1,1)
Text.TextScaled = true
Text.Font = "SourceSansLight"
Text.BackgroundTransparency = 1
Text.Position = UDim2.new(-2,0,-0.5,0)
Part.AlwaysOnTop = true
Text.Text = cookies -- what i need help with
How do I make the script keep on the script to keep on checking the numbers?
1 answer
Well you can create a loop to change that text
Let's use a while loop for this
while true do wait()
end
it's important to remember for a while loop to place a wait() somewhere in there so it doesnt crash your game
Next inside the loop let's change the Text of Text to what the value of the cookies variable is
while true do wait()
Text.Text = plr.PlayerGui["Cookies/CPS"].Frame.Cookies.text
end
Take note of how I went to plr.PlayerGui instead of game.StarterGui, also its best if you make the wait a bit longer to not add to the lag, although it is little in this case.
Unrecommended version, Scroll down
local plr = game.Players.LocalPlayer
Humanoid = game.Workspace:WaitForChild(plr.Name)
Part = Instance.new("BillboardGui",Humanoid.Head)
Text = Instance.new("TextLabel",Part)
Part.ExtentsOffset = Vector3.new(0,3,0)
Part.Size = UDim2.new(1,1,1,1)
Text.Size = UDim2.new(5,0,1,1)
Text.TextScaled = true
Text.Font = "SourceSansLight"
Text.BackgroundTransparency = 1
Text.Position = UDim2.new(-2,0,-0.5,0)
Part.AlwaysOnTop = true
while true do wait()
Text.Text = plr.PlayerGui["Cookies/CPS"].Frame.Cookies.text
end
If you want a more efficient way to change the text we can create a changed event function to only change the text of text when the text of that gui changes
plr.PlayerGui["Cookies/CPS"].Frame.Cookies.Changed:connect(function(c)
if c=="Text" then
Text.Text=plr.PlayerGui["Cookies/CPS"].Frame.Cookies.Text
end
end)
c is the property that was changed
Good one
local plr = game.Players.LocalPlayer
Humanoid = game.Workspace:WaitForChild(plr.Name)
Part = Instance.new("BillboardGui",Humanoid.Head)
Text = Instance.new("TextLabel",Part)
Part.ExtentsOffset = Vector3.new(0,3,0)
Part.Size = UDim2.new(1,1,1,1)
Text.Size = UDim2.new(5,0,1,1)
Text.TextScaled = true
Text.Font = "SourceSansLight"
Text.BackgroundTransparency = 1
Text.Position = UDim2.new(-2,0,-0.5,0)
Part.AlwaysOnTop = true
plr.PlayerGui["Cookies/CPS"].Frame.Cookies.Changed:connect(function(c)
if c=="Text" then
Text.Text=plr.PlayerGui["Cookies/CPS"].Frame.Cookies.Text
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Ok, so if I want it to check the number of players I would do "Changed"
@BePwnda game.Players.PlayerAdded:connect or game.Players.PlayerRemoved:connect