✓ Accepted answer
Excuse my ignorance on the matter, as I haven't actually done anything in Studio for a good year. I can't remember if the server can make changes to the PlayerGui, although I thought they could. As such, I'll provide a server and a local option.
Ziffxture was correct, you should not be using .CharacterAdded:Wait(). Instead, you should simply connect it to a function, as you did with .PlayerAdded.
Server
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
for i = 1,20 do
local text = plr:WaitForChild('PlayerGui'):FindFirstChild('ScreenThings'):FindFirstChild('ShowingMoneyFrame'):FindFirstChild('HonksText')
text.Text = 'Honks: '.. plr:FindFirstChild('leaderstats'):FindFirstChild('Honks').Value
wait(1)
end
end)
end)
Local
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
Player.CharacterAdded:Connect(function(Character)
for i = 1,20 do
local text = Player:WaitForChild('PlayerGui'):FindFirstChild('ScreenThings'):FindFirstChild('ShowingMoneyFrame'):FindFirstChild('HonksText')
text.Text = 'Honks: '.. Player:FindFirstChild('leaderstats'):FindFirstChild('Honks').Value
wait(1)
end
end)
So there are two options, keeping in mind that the LocalScript will have to be placed appropriately.
I also do not recommend using so many :FindFirstChild()s. In the first place, their usage in your case is completely irrelevant. The point of using the method is to make sure an instance exists before you attempt to interact with it, thus avoiding the dreaded attempt to index a nil value error. However, in your line of code immediately after declaring the variable text, you're trying to changing the Text property of the instance. This means that if, for some reason, the instance did not exist, you would be indexing a nil value, nullifying the purpose of your usage of :FindFirstChild(). To solve this, or rather make it more helpful, use a simple if statement.
local Object = workspace:FindFirstChild("Object")
if Object then
Object.Name = "Found!"
end
4 comments
What's the goal You want it to do for beside changing the text?
Use a local script in the screen gui
The Wait method of the RBXScriptSignal base class does not accept callbacks, only a timeout; the Character Instance is only added after death, upon joining the CharacterAdded event will not fire.
lol im done with this but im just confused why nobody is questioning the currency name? im sure yall see some weird stuff on here but 'Honks' Is very odd- XD