Hi everyone!
I was making a game where it would detect which items you would use when you were beating an obby (For example "Boost Items Used"). Here is the code I wrote in a local script.
function check(c)
for i, v in pairs(c:GetChildren()) do
if v.Name=='Helicopter Crystal' or 'Low Gravity Crystal' or 'Big Boing' then
print(v.Name) -- prints out all of the children inside the player's characdter, one by one
game.ReplicatedStorage.ItemUsed:Fire(v.Name)
end
end
end
function bind(c)
if not c then return end
check(c)
c.ChildAdded:Connect(function()check(c)end)
end
bind(game.Players.LocalPlayer.Character)
game.Players.LocalPlayer.CharacterAdded:Connect(bind)
For some reason all of the player character's children is detected as an item, even though their names arent 'Helicopter Crystal' or 'Low Gravity Crystal' or 'Big Boing'. Can someone help me figure out why?
Thanks in advance.
