#Ganky script

72 messages · Page 1 of 1 (latest)

frigid orchid
#

"if it ain't broke, don't fix it"

#

nah but uh

#

What errors about the 5% of the time

wet remnant
#

nothing errors ive just had times it didnt clone the item into my backpack

frigid orchid
#

Why are you remaking a player variable

#

when you already have one

#

@wet remnant

wet remnant
#

on which lines?

frigid orchid
#

line 9

#

you remade the player variable

#

you already had player in the loop of all players

wet remnant
#

i didnt have the specific player tho,
for _, Player in pairs(Players:GetChildren()) do gets every player in the game

frigid orchid
#

i know

#

thats what i said

#

I said why did you

wet remnant
#

do i not have to?

frigid orchid
#

You do not

#

ohh

#

yeah you don't have to

#

but i didnt realize what u sai

frigid orchid
#

that _, player <-- is the player ur currently at

#

you already have player specified

torpid geyser
#

Why do you check every single descendant of the player for a single thing

naive foxBOT
#

studio** You are now Level 5! **studio

torpid geyser
#

Inside of your first for loop, you could do a conditional to check for the specific object

#

Could help fix the script

wet remnant
torpid geyser
#

A conditional is an "if then" statement

#

So in your case

#

Inside your first loop:

#

    
    for _, Player in pairs(Players:GetPlayers()) do
if Player:FindFirstChildOfClass("BoolValue") then

local FoundObject= Player:FindFirstChildOfClass("BoolValue")

local plr = Player
                if Players[plr].Backpack:FindFirstChild(FoundObject.Name) == nil and game.Workspace[plr]:FindFirstChild(FoundObject.Name) == nil then
                    local CloneCup = Cups[FoundObject.Name]:Clone()
                    CloneCup.Parent = Players[plr].Backpack
                end        
      
end       

end```
#

Wrote this on the phone

#

So there's bound to be error

#

But should get my point across

#

This should work unless you wanna check super deep into the player which then you would require your descendants loop

wet remnant
#

the boolvalue is within a folder of the player, Will FindFirstChildOfClass() still be able to find the boolvalue?

torpid geyser
#

In this case, you are going to use "FindFirstChildOfClassWhichIsA()"

#

Long ass method ik

#

This accepts 2 parameters: the class object, and a boolean

#

Hardly anyone knows about the second parameter

#

If it is true, than the method becomes recursive, and checks all descendants

#

Or , if you know the name of the boolean, you can use "FindFirstChild()" which has the same parameters, except the first parameter is the actual name of the object

wet remnant
torpid geyser
#

:findfirstchildofclasswhichisa() is a unique method, that can either find an immediate child of a parent, or search the descendants until it finds what its looking for.

When used, most people want it for the immediate route:

"game.Workspace:FindFirstChildOfClassWhichIsA("BoolValue")"

This would find the first BoolValue inside workspace. When doing this, the second parameter is automatically set to false.

In order to have it recursive (aka use it to check all descendants) , we need to tell it to become recursive:

"game.Workspace:FindFirstChildOfClassWhichIsA("BoolValue",true)"

In this case, the boolvalue doesn't have to be directly inside workspace, it could be in a model or character model.

Does this make sense?

#

(This is the same with findfirstchild() )

wet remnant
#

Yeah that makes much more sense now, But how am i suppose to use :FindFirstChildWhichIsA() on a Player?

#

Im getting errored with FindFirstChildOfClassWhichIsA is not a valid member of Player

torpid geyser
#

: not .

#

Can I see what u wrote?

wet remnant
#

``while wait(.5) do
for _, Player in pairs(Players:GetPlayers()) do
if Player:FindFirstChildOfClassWhichIsA("Folder","BoolValue") then

        local FoundObject= Player:FindFirstChildOfClassWhichIsA("BoolValue", true)
        print(FoundObject.Name)

        local plr = Player
        if Players[plr].Backpack:FindFirstChild(FoundObject.Name) == nil and game.Workspace[plr]:FindFirstChild(FoundObject.Name) == nil then
            local CloneCup = Cups[FoundObject.Name]:Clone()
            CloneCup.Parent = Players[plr].Backpack
        end        
    end
end

end``

#

bruh

torpid geyser
#

Almost, not quite

#

Findfirstchildofclasswhichisa() has 2 parameters, a string (in your case "BoolValue") and a boolean value (true or false)
The first parameter should be "BoolValue" the second should be true

#

You did it right the second time, messed up the first time

wet remnant
#

wow

#

i changed the wrong line

torpid geyser
#

Lol

#

Again, I'm on the phone so my help is limited

wet remnant
#

am i suppose to be using FindFirstChildOfClassWhichIsA() or FindFirstChildWhichIsA()

torpid geyser
#

Findfirstchildofclasswhichisa()

#

FindFirstChildWhichIsA() doesn't have a recursive parameter

#

Oh wait, I think one is just deprecated, I think you can use either

wet remnant
#

alright, well i got everything to work with this script,

Players = game:GetService('Players')
Cups = RepStorage.Cups

wait(1)
while wait(.5) do
    for _, Player in pairs(Players:GetPlayers()) do
        if Player:FindFirstChildWhichIsA("BoolValue", true) then
            
            local FoundObject = Player:FindFirstChildWhichIsA("BoolValue", true)
            print(FoundObject.Name)

            local plr = Player
            if Player.Backpack:FindFirstChild(FoundObject.Name) == nil and game.Workspace[plr.Name]:FindFirstChild(FoundObject.Name) == nil then
                local CloneCup = Cups[FoundObject.Name]:Clone()
                CloneCup.Parent = Player.Backpack
            end        
        end
    end
end```
#

i cant even find FindFirstChildOfClassWhichIsA() as a method under instances so I just used FindFirstChildWhichIsA()

torpid geyser
#

If that one works then use that one , if it works it works!

wet remnant
#

Alright well thank you guys for all the help

wet remnant
#

alright

#

changed lots of things up but heres the final script