#why is my script ignoring the for i,v in ipairs do?

1 messages · Page 1 of 1 (latest)

amber flame
#

does it print hello

urban bronze
#

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

amber flame
#

is that the whole script?

urban bronze
#

yes

amber flame
#

repeat wait() until game.Players.numPlayers >= 0
where are you getting "numPlayers"

urban bronze
#

from players?

amber flame
#

i never seen that used. i would do :
#game.Players:GetChildren()
cuz that will give the number of players in the game

urban bronze
#

but it works.

#

@amber flame

#

But that doesnt answer my question somehow.

#

i just asked why my script ignores the for i,v

amber flame
#

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

amber flame
#

are you getting any error messages

urban bronze
#

oh right

urban bronze
#

zero output

amber flame
#

where do you have your script

urban bronze
#

in serverscriptservice

#

btw ignore math

#

i use it for fun

amber flame
#

this is what i get when i run the script

#

which means the lines of code in the loop are running

urban bronze
#

how do i make all players get an pistol then

#

it doesnt even work with function

stray gull
urban bronze
#

i moved it to function

#

still didnt fork

urban bronze
#

that was solved

#

now i need to see why my script ignores my function.

amber flame
amber flame
zealous cedarBOT
#

studio** You are now Level 10! **studio

urban bronze
#

i have trust issues

amber flame
#

you can make a copy of the game and let me join the copy and not the main

urban bronze
#

the game is simple

#

there is no back code

#

there is just 3 models

#

that does not interact with any script

#

there you go

amber flame
#

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?

urban bronze
#

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()

amber flame
#

why do you even have the weapons in lighting

urban bronze
#

idk

stray gull
urban bronze
#

wait

#

i put it on debris?

stray gull
#

What?

amber flame
#

bro what

urban bronze
#

wait what year is it rn

#

4

stray gull
#

??

amber flame
#

bro just download a copy of the game and send it

zealous cedarBOT
#

studio** You are now Level 11! **studio

carmine narwhal
#

Bros just waffling

urban bronze
#

bruh

amber flame
#

bro like do you need help or na idk if ur trolling

urban bronze
#

wdym

#

all i asked was

#

why does my for i,v doesnt work...

#

hello3

stray gull
#

Did you put like a print inside the for i,v?

urban bronze
stray gull
#

So you can do it to see if that's the issue, if it doesn't print anything in the output

amber flame
#

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()

urban bronze
#

are we deadhuzzz

#

?

amber flame
#

did you paste that in

carmine narwhal
#

Why u even using message

urban bronze
#

dude

#

i use message all the time...

carmine narwhal
#

i would refrain from using deprecated objects

urban bronze
#

b-but theyre retro 🥺

amber flame
#

gl with ur game bro

stray gull
urban bronze
#

no?

carmine narwhal
stray gull
#

So what is it?

urban bronze
urban bronze
stray gull
carmine narwhal
#

it’s a message bro

#

😂

urban bronze
amber flame
urban bronze
#

even tho i first joined in 2018

carmine narwhal
#

i was answering about the system

stray gull
#

Ohh i get it now

urban bronze
stray gull
#

Well just make yourself one with text label

carmine narwhal
# urban bronze B-But i want it retro

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

zealous cedarBOT
#

studio** You are now Level 10! **studio

carmine narwhal
#

there u go

stray gull
#

It's better than using deprecated things tbh

urban bronze
#

AHH

#

IT HURTS

#

I DONT WANNA SEE IT

#

NOT RETRO

carmine narwhal
#

literally the same 😂

urban bronze
#

NO IT ISNT

carmine narwhal
#

replica of the effect

stray gull
#

Then make it the way you want?

urban bronze
# carmine narwhal Create a TextLabel Set Size to {1,0},{1,0} Position to {0.5,0},{0.5,0} Anchor...

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()

drifting topaz
# urban bronze

If you want to get the specific player object, it’s probably better to use game.Players:GetPlayers() then game.Players:GetChildren()

haughty hill
#

why ipairs

stray gull
haughty hill
#

u dont need that too

#

the for loopis not working cuz its placed wrong

#

everything is fine

#

its just placed wrong

stray gull
#

I thought the problem was that he was using a deprecated instance

haughty hill
#
    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

urban bronze
#

ur too late

#

too SAD!

#

BAD!