for i, v in pairs(script.Parent:GetChildren()) do
v.Touched:connect(function(hit)
if hit.Parent == game.Workspace.Wall then
print ("false")
end
end)
end
i honestly dont know where i went wrong i basically just want a script that when a model touches a wall it does something i tried fixing this a few times writing the code differently but idk why
Since you’re using :GetChildren() on the parent of the script, you will also get the script in the table of children returned. You must check if the child is a Base Part since base parts have the Touched event, not scripts.
for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:connect(function(hit)
if hit.Parent == game.Workspace.Wall then
print ("false")
end
end)
end
end