the entity moving should detect that it hit door and do stuff
but it doesnt work
script.Parent.Touched:Connect(function(v)
print(v)
if v.Name == "door" then
if v.Parent.Name == "new" then
for i,v in pairs(v.Parent:GetChildren()) do
if v.Name == "Locker1" or "Locker2" then
script.Parent.Parent.Script:Destroy()
local t = TweenInfo.new(
0.25,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In
)
local tween = game:GetService("TweenService")
local function twennc(part,info,prop)
local success,warn = pcall(function()
tween:Create(part,info,prop):Play()
end)
end
twennc(script.Parent, t, {CFrame = v.f.CFrame})
twennc(v.door, t, {CFrame = v.doorto.CFrame})
game.Players:FindFirstChild(v.plr.Value).Character.Humanoid.Health = 0
wait(0.25)
twennc(v.door, t, {CFrame = v.doorog.CFrame})
end
end
end
end
end)
The variable name in the loop is the same as in the touched event, it can cause problems, and where is the script located? And what doesn’t it print? v?
This event only fires as a result of physical movement, so it will not fire if the CFrame property was changed such that the part overlaps another part. This also means that at least one of the parts involved must not be Anchored at the time of the collision.
Well than nothing else matters if we can’t get past that…
Is this a client script? with a server script already doing things to this object?
Is touch even set up on the part? Is the part covered?
Make a part right next to it with a simple touch script that just prints ("x’)
as a test.
You should switch to try and use Instance:GetPartBoundsInBox(). Then check if the entity is touching any part which in this is Hitbox? and if it is then do the same logic you have here.
I assume this would work better because as said below which was said above lol
This event only fires as a result of physical movement, so it will not fire if the CFrame property was changed such that the part overlaps another part. This also means that at least one of the parts involved must not be Anchored at the time of the collision.
— BasePart documentation on the .Touched event.
This article below links you to the Documentation which states
"WorldRoot:GetPartBoundsInBox() returns an array of parts whose bounding boxes overlap a box whose volume is described using the given center (CFrame) and size (Vector3). "
This means that it is based on the given CFRAME and not what .Touched uses.
Yes, for a normal Touched event it shouldn’t but Touched only works on Physical movement. Example if you anchor your Character and the descendants in workspace and put a kill brick it should not in theory kill you because you’re anchored and not putting out any physical movement.
Then I’m sure this is not a problem of the script, but the parts themselves. For some reason the part doesn’t detect touches. Can you share us their properties?