I have the following code that does not do what I want. I want to make it so that for every player, an announcement shows up letter by letter, just like Daxter33's Paintball! announcements. I tried this but wont work, no errors too.. Could someone help me please?
Players = game.Players:GetChildren() function Deathmatch() wait(2) Time = 5 for i = 1,#Players do String = "Round Chosen: Deathmatch" for b = 1,#String do Players[i].Backpack.GameHint.TextLabel.Text = Players[i].Backpack.GameHint.TextLabel.Text..String:sub(b) wait(.2) end end end game.Players.PlayerAdded:connect(Deathmatch)
Recheck your code, and you'll find a few mistakes; You are using the 'GetChildren' method, but you may be wondering, 'what is wrong with that?', well, if there was a 'Hat' type instance in 'Players', GetChildren
will count the hat aswell, let's try using the 'GetPlayers' instead. :)
local Players = game.Players:GetPlayers() --The 'GetPlayers' method gets all current 'Player' type instances that is in 'Players', so if there were to be a 'Hat' instance, it would return as 'nil' function Deathmatch() wait(2) local Time = 5 --What is 'Time' used for? for i,v in pairs(Players) do --Ya, I switch out your old 'for' loops with a more efficient one :) if v then --Check if 'Player' is existant String = "Round Chosen: Deathmatch" for i2,v2 in pairs(String) do if v:FindFirstChild("PlayerGui") and v.PlayerGui:FindFirstChild("GameHint") and v.PlayerGui.GameHint:FindFirstChild("TextLabel") then --Checks to see if 'PlayerGui', 'GameHint', and 'TextLabel' are existant within 'Player' v.PlayerGui.GameHint.TextLabel.Text = v2:sub(1,i) --Ah, now doesn't this look much better? :) end wait(1/19) end end end end game.Players.PlayerAdded:connect(Deathmatch) --Connects the function 'Deathmatch' to the event; fires when a Player joins for i,v in pairs(Players) do Deathmatch() end --The 'PlayerAdded' event does not work in Studio mode, so you use this :)
Also, GUIs
do not show up in the 'Backpack', they show up only in the Player's 'PlayerGui', 'SurfaceGui', or 'BillboardGui', which is why I switch your code from Backpack
to PlayerGui
.
Hope this helped!
Alright, I will fix your code up for you just to make it work, good luck!
local Players = game:GetService("Players"):GetPlayers() function Deathmatch() wait(2) Time = 5 for _,Player in pairs(Players) do local String = "Round Chosen: Deathmatch" for i = 1,#String do Player.Backpack.GameHint.TextLabel.Text = tostring(String:sub(1, i)) wait(0.2) end end end game:GetService("Players").PlayerAdded:connect(Deathmatch)