I just want to check ALL of the players humanoid root parts for the child stick. If you could give me the script it would be much appreciated.
Cause i really dont get it. I tried the i,v loop n stuff i jsut dont get it.
Whatâs your new code @BMWLux ?
@DybalaplaysYT GetDescendants would get everything in the workspace thatâs inside it, I think thatâs unnecessary if the OP knows that a stick is going to be in the workspace and he only wants to check whatâs inside a characterâs humanoidrootpart
but if you look at the original post, he said he wants to check if the object exists in the workspace and in any of the games humanoidrootparts
So basically Im trying to see if an object exists in the workspace and in any of the games
humanidrootparts.
and GetDescendants() can do all of this in one thread
this is the simplest i can do
for i,v in pairs (workspace:GetDescendants()) do
if v.Name == "Stick" then
print("Stick found")
end
end
since the playerâs Character HumanoidRootPart are descendants of workspace, It will check their HumanoidRootParts too
it will? But like it will also find the workspace. How can I check if there is two of them and if so then delete one.
for i, plr in pairs(game.Players:GetChildren()) do
wait(0.1)
local character = plr.Character
for _, obj in pairs(character:GetChildren()) do
wait(0.1)
if obj.Name == âHumanoidRootPartâ then
if character.HumanoidRootPart:FindFirstChild(âStickâ) then
game.Workspace:FindFirstChild(âStickâ):Destroy()
print("ObjWithHRPFound")
end
end
end
end
But like is this possbile? If so how could I do it?
I think this script would help, did a boolean check if a rootpart has a stick and then it will check to destroy a stick in a workspace.
local Players = game:GetService("Players")
while true do
local FoundStickInCharacter = false
for _, Player in pairs (game.Players:GetChildren()) do
if Player and Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") then
local RootPart = Player.Character:FindFirstChild("HumanoidRootPart")
if RootPart:FindFirstChild("Stick") then
FoundStickInCharacter = true
end
end
end
if FoundStickInCharacter == true and game.Workspace:FindFirstChild("Stick") then
print("Stick found in child of workspace")
game.Workspace:FindFirstChild("Stick"):Destroy()
elseif FoundStickInCharacter == true and not game.Workspace:FindFirstChild("Stick") then
print("No stick found in child of workspace")
end
wait(0.25)
end
Fr. If this works I will heart every one of your comments XD
local foundalreaady = false
for i,v in pairs (workspace:GetDescendants()) do
if v.Name == "Stick" and foundalready == false and v.Parent ~= workspace then
print("Stick found")
v:Destroy()
foundalready = true
elseif v.Name == "Stick" and foundalready == true and v.Parent == workspace then
print("Found a stick that is child of workspace. Keeping Stick.")
end
end
Same to you lol Muchas Gracias
WORKS! LETS GOOGOOO THANK YOU!