I’ve made a touched event when a part is touched, but when the thing that I want to fire it (a MeshPart) touches it, it doesn’t fire. I’ve tried testing it with other parts, and sometimes it works.
Server script inside the part:
script.Parent.Touched:Connect(function(hit)
print("e")
if hit.Name == "Train" and hit:FindFirstChild("Moving") then
print("a")
local explos = Instance.new("Explosion")
explos.Position = script.Parent.Position
explos.Parent = script.Parent
explos.BlastPressure = .4
hit.Parent.TrainHandler.Disabled = true
hit.Chug:Stop()
for i = 20,1,-1 do
local End = hit.Parent:GetPrimaryPartCFrame()*CFrame.Angles(math.rad(90),0,0)
local start = hit.Parent:GetPrimaryPartCFrame()
hit.Parent:SetPrimaryPartCFrame(start:lerp(End,i))
end
script.Parent.Explosion:Play()
end
end)
It clearly says he put it in a (Server)Script inside the part, so he should be fine on the type of script, please read through before jumping ahead and trying to answer questions, that are already provided in the topic.
@Fondatix I tried this and it worked perfectly fine, did you maybe accidentally put it inside a descendant or something?
Touched events do not fire for anchored parts. Touched will only fire for parts that intersect through physics simulation - that is, one part touches another naturally. This is noted in the Touched documentation page and explained in the Anchored documentation page.
The post approval had said that touch events won’t fire for parts that are anchored, one part has to move physically on it’s own for a better understanding. NO CFRAME MOVING!
So you know when people create custom characters they have a “FakeHead” you can make a non-colliding invisible base of the train and have the part touch that instead of the actual engine.
(You can make an invisible part that goes around the whole engine and set can collide to off)