I have encountered some awkward behaviour and I would appreciate any help in dealing around this.
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0 ) -- infinite tween
-- dummy part which will be tweened, positioned at 0,-5,0
local dummyPart = Instance.new("Part", workspace)
dummyPart.Position = Vector3.new(0,-5,0)
dummyPart.Anchored = true
dummyPart.CanCollide = true
dummyPart.Touched:Connect(function(touchedPart) -- action taken when touch detected
print('touch detected: ', touchedPart.Name) -- print something for testing purposes
end)
local tweenGoal = {}
tweenGoal.Position = Vector3.new(0,5,0)
TweenService:Create(dummyPart, tweenInfo, tweenGoal):Play() -- create & play tween
Looking at the above code, a dummy part is being tweened through the baseplate and back infinitely. But the Touched
event is fired when my Humanoid touches the part but not when the baseplate is touched.
How can I get the Touched
event to fire when baseplate is touched?
It works when I make one of the parts (baseplate or dummy part) as not anchored, but I want both to be anchored. Some people have suggested to use an inifinite loop and use the GetTouchingParts() to understand if there is a touching part or not but this is really odd - it is a hack. I want to get the Touched
event to fire.
What are my options?