#Ganky script
72 messages · Page 1 of 1 (latest)
nothing errors ive just had times it didnt clone the item into my backpack
on which lines?
line 9
you remade the player variable
"local plr = Descendants.Parent.Parent.Name"
you already had player in the loop of all players
i didnt have the specific player tho,
for _, Player in pairs(Players:GetChildren()) do gets every player in the game
do i not have to?
yes, it gets everyplayer but one by one
that _, player <-- is the player ur currently at
you already have player specified
Why do you check every single descendant of the player for a single thing
this too
** You are now Level 5! **
Inside of your first for loop, you could do a conditional to check for the specific object
Could help fix the script
what do you mean by conditional script?
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
the boolvalue is within a folder of the player, Will FindFirstChildOfClass() still be able to find the boolvalue?
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
can you explain this more?
: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() )
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
``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
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
am i suppose to be using FindFirstChildOfClassWhichIsA() or FindFirstChildWhichIsA()
Findfirstchildofclasswhichisa()
FindFirstChildWhichIsA() doesn't have a recursive parameter
Oh wait, I think one is just deprecated, I think you can use either
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()
If that one works then use that one , if it works it works!
Alright well thank you guys for all the help