#why is my script ignoring the for i,v in ipairs do?
1 messages · Page 1 of 1 (latest)
does it print hello
no.
the msg.text = text, the "text"" is from the function.
when doing the message("hello") it sets the text of the msg to the "text" of the function
is that the whole script?
yes
repeat wait() until game.Players.numPlayers >= 0
where are you getting "numPlayers"
from players?
i never seen that used. i would do :
#game.Players:GetChildren()
cuz that will give the number of players in the game
but it works.
@amber flame
But that doesnt answer my question somehow.
i just asked why my script ignores the for i,v
well if something gets ignored then i think there has to be a problem happening in the lines of code before that
ok i put the code in a script and i changed the first line of code with:
repeat wait() until #game.Players:GetPlayers() > 0
and it worked
u sure?
are you getting any error messages
oh right
where do you have your script
this is what i get when i run the script
which means the lines of code in the loop are running
Wouldn't it be better with game.Players:GetPlayers()?
i already added :getplayers.
that was solved
now i need to see why my script ignores my function.
ye u right my mistake
i think this might be easier if you let me join your studio, would you be down for that?
i dont trust any people
** You are now Level 10! **
i have trust issues
you can make a copy of the game and let me join the copy and not the main
the game is simple
there is no back code
there is just 3 models
that does not interact with any script
there you go
repeat wait() until #game.Players:GetPlayers() > 0
function message(text)
local msg = Instance.new("Message", workspace)
msg.Name = "GameMessage"
msg.Text = text
end
function endmessage()
if workspace:WaitForChild("GameMessage") ~= nil then
workspace:WaitForChild("GameMessage"):Destroy()
else
return
end
end
message("hello")
for i,v in ipairs(game.Players:GetChildren()) do
local gun = game.Lighting.Weapons.Pistol:Clone()
gun.Parent = v.Backpack
end
wait(3)
endmessage()
so this doesnt work?
wait
this is the new code
repeat wait() until #game.Players:GetPlayers() > 0
function weapon()
for i,v in ipairs(game.Players:GetPlayers()) do
local gun = game.Lighting.Weapons.Pistol:Clone()
gun.Parent = v.Backpack
end
end
function message(text)
local msg = Instance.new("Message", workspace)
msg.Name = "GameMessage"
msg.Text = text
end
function endmessage()
if workspace:WaitForChild("GameMessage") ~= nil then
workspace:WaitForChild("GameMessage"):Destroy()
else
return
end
end
message("hello")
weapon()
wait(3)
endmessage()
why do you even have the weapons in lighting
idk
Put it in replicated storage or server storage
What?
bro what
??
bro just download a copy of the game and send it
** You are now Level 11! **
Bros just waffling
that is all of the script
bruh
bro like do you need help or na idk if ur trolling
im not trolling bro
wdym
all i asked was
why does my for i,v doesnt work...
hello3
Did you put like a print inside the for i,v?
no
So you can do it to see if that's the issue, if it doesn't print anything in the output
well idk what to tell you bro, the script ima send rn literally runs the loop
repeat wait() until #game.Players:GetPlayers() > 0
function message(text)
local msg = Instance.new("Message", workspace)
msg.Name = "GameMessage"
msg.Text = text
end
function endmessage()
if workspace:WaitForChild("GameMessage") ~= nil then
workspace:WaitForChild("GameMessage"):Destroy()
else
return
end
end
message("hello")
for i,v in ipairs(game.Players:GetChildren()) do
local gun = game.Lighting.Weapons.Pistol:Clone()
gun.Parent = v.Backpack
end
wait(3)
endmessage()
did you paste that in
Why u even using message
i would refrain from using deprecated objects
b-but theyre retro 🥺
gl with ur game bro
I mean like, i think you want to make a chat bubble right?
no?
make it with a text label 😀
So what is it?
too lazy
my for i,v is getting ignore
I'm talking about your system, not this part
B-But i want it retro
this is what it looks like
even tho i first joined in 2018
i was answering about the system
Ohh i get it now
it basically just generates an message
Well just make yourself one with text label
Create a TextLabel
Set Size to {1,0},{1,0}
Position to {0.5,0},{0.5,0}
Anchor point to 0.5, 0.5
Set background color to [128, 128, 128]
Set BackgroundTransparency to 0.5
Set BorderSizePixel to 0
Set FontFace to Arial
Set TextSize to 21
Set TextStrokeTransparency to 0
** You are now Level 10! **
there u go
It's better than using deprecated things tbh
literally the same 😂
NO IT ISNT
replica of the effect
Then make it the way you want?
repeat wait() until #game.Players:GetPlayers() > 0
function weapon ()
for i,v in pairs(game.Players:GetChildren()) do
local gun = game.ReplicatedStorage.Weapons.Pistol:Clone()
gun.Parent = v.Backpack
end
end
function message(text)
local msg = Instance.new("ScreenGui", game.StarterGui)
local textr = Instance.new("TextLabel", msg)
textr.Size = UDim2.new(1,0,2,0)
textr.Position = UDim2.new(0,0,-0.5,0)
textr.BackgroundTransparency = 0.5
textr.TextSize = 45
msg.Name = "GameMessage"
textr.Text = text
end
function endmessage()
if game.StarterGui:WaitForChild("GameMessage") ~= nil then
game.StarterGui:WaitForChild("GameMessage"):Destroy()
else
return
end
end
weapon()
message("hello")
wait(3)
endmessage()
If you want to get the specific player object, it’s probably better to use game.Players:GetPlayers() then game.Players:GetChildren()
why ipairs
He changed it to pairs in the new script
u dont need that too
the for loopis not working cuz its placed wrong
everything is fine
its just placed wrong
I thought the problem was that he was using a deprecated instance
for i,v in game.Players:GetChildren() do
print(v)
local gun = Instance.new("Tool",workspace):Clone()
gun.Parent = v.Backpack
end
task.wait(3)
if workspace:WaitForChild("GameMessage") ~= nil then
workspace:WaitForChild("GameMessage"):Destroy()
else
return
end
end```
this works
I changed a bit
for my own testing
but this is how u should do it
yo,,,
ur too late
too SAD!
BAD!