Ive tweened a model (Train) and supposedly I have a part that if the tween touches it then it will slow down. And I have checked if the tween is touching the part with a print statement and its recieved nothing at all. Any help on how to detect if a tween touched a part?
local repStore = game:GetService("ReplicatedStorage")
local slowEvent = repStore:WaitForChild("SlowEvent")
script.Parent.Touched:Connect(function(hit)
if hit.Name == "PrimaryPart" then
print("yes")
slowEvent:Fire()
end
end)
Tweens do not simulate physics and by extension, they will not fire Touched event for anchored parts.
You can unanchor the not-tweened part or attach special invisible “detector” part to the train via AlignPosition and AlignOrientation constraints, with RigidityEnabled set to true. Such detector cannot be anchored.
That being said, tweening train is not ideal, as players that are not on train seats will “slide off” of moving train. Unless that is enough for you.
Since tweens are 100% predictable, there are other ways to solve train position detection. Touched should be used in cases that at least one part in unanchored.