This script doesn't work and no Output helps here, please point out what is incorrect, thank you.
function onTouched(hit) local C = hit.Parent:GetChildren() if C.classname == "Hat" then C:remove() end end script.Parent.Touched:connect(onTouched)
Thanks
As stated by Perci1 in the comments, responding to your post, Lua is case-sensitive and standardly utilizes Camel Case. Therefore, the property ClassName must be written as designated earlier in this post. Additionally, you do not access all children simply through GetChildren(). It returns a table.
A table can be iterated through using the next function in a for-loop.
Touched does not only return Character interaction, therefore it would be wise to perform a conditional check of the object before proceeding.
The fixed code would look as follows:
function onTouched(hit) if not(hit.Parent:FindFirstChild'Humanoid') then return end; for i,v in next,hit.Parent:children'' do if(v.ClassName=='Hat') then v:Destroy(); end; end; end; script.Parent.Touched:connect(onTouched)
Hope this helped. Also, remember that the wiki is a helpful place to go for scripting functionality in RBX.lua.