I probably missed something.
Anyway the script is supposed to let only a player pass a transparent wall.
local part = script.Parent
local function CanCollide(otherPart)
local partParent = otherPart.parent
local humanoid = partParent:FindFirstChild("Humanoid")
if humanoid then
part.CanCollide = false
wait(3)
part.CanCollide = true
end
end
it has too many errors according to me… local partParent = otherPart.parent el parent esta mal escrito hagalo asi: local partParent = otherPart.Parent
In addition, we cannot answer clearly since we do not know how the function is triggered or if the part has the CanTouch activated, we practically do not know anything about the script
Your script is not completed, so i added some things
local part = script.Parent
local function CanCollide(otherPart)
local partParent = otherPart.parent
local humanoid = partParent:FindFirstChild("Humanoid")
if humanoid then
part.CanCollide = false
wait(3)
part.CanCollide = true
end
end
It is a script, but i changed the RunContext to Client.
Yes, the script is inside the part.
Crap, I forgor to put the line part.Touched:Connect(CanCollide())
Yes, there are errors in Output, it says attempted to index nil with Parent
took all of your tips and came up with this, still had the index nil error:
local part = script.Parent
local function CanCollide(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChild("Humanoid")
if humanoid then
part.CanCollide = false
wait(3)
part.CanCollide = true
end
end
part.Touched:Connect(CanCollide())
The issue is that instead of connecting the function, you are calling the function then connecting nil. It should be
local part = script.Parent
local function onHit(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildOfClass("Humanoid")
if humanoid then
part.CanCollide = false
task.wait(3)
part.CanCollide = true
end
end
part.Touched:Connect(onHit)