Hello, I’m having some troubles with a weld and how it moves.
Here you can see the structure of my inspector:
The DetectingZone is a cylinder that moves between paths using tweenService.
Inside I have a mesh and a spotlight and I want them to follow the DetectingZone, I think the best option was to create a weld so they will be attached and follow this part, but they stay static in the scene without moving and I see how the cylinder move.
What’s wrong with this? Maybe i need to do it different way?
When I tried to get the .CFrame of the part i got this error:
TweenService:Create property named 'PrimaryPart' cannot be tweened due to type
mismatch (property is a 'Object', but given type is 'Dictionary')
The code I got was this one:
local function moveModelToPosition(position)
local tweenInfo = TweenInfo.new(moveDuration, Enum.EasingStyle.Linear)
local targetPosition = position
local primaryPart = vigilanceFocus.PrimaryPart
local initialPosition = primaryPart.Position
local distance = (initialPosition - targetPosition).Magnitude
local tween = game:GetService("TweenService"):Create(vigilanceFocus, tweenInfo, {PrimaryPart = {CFrame = CFrame.new(targetPosition)}})
tween:Play()
tween.Completed:Connect(function()
local finalDistance = (vigilanceFocus.PrimaryPart.Position - targetPosition).Magnitude
if finalDistance > marginError then
print("Error")
end
currentIndex = currentIndex % totalPositions + 1
position = positions[currentIndex]
moveModelToPosition(position)
end)
end