So, I’m making a spotlight that moves up and down when it’s clicked. I had the Welds and everything working, then I tried to make it work with a moving vehicle. I have the parts I want to move welded to a part, that is inside a part I do not want to move. When I anchor that part I don’t want to move onto the vehicle, it breaks the tween and won’t animate. Without the anchor, the part won’t move with the vehicle at all. Any solutions?
Tween/Light Script:
local tService = game:GetService("TweenService")
local clickDetector = script.Parent.ClickDetector
local enabled = script.Parent.enabled
local body = script.Parent.body
local light = script.Parent.light
local emitter = script.Parent.light.SpotLight
enabled.Value = false
local tweenInfo = TweenInfo.new(4,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local upTween = tService:Create(body,tweenInfo, {CFrame = body.CFrame + Vector3.new(0,4,0)})
local downTween = tService:Create(body,tweenInfo, {CFrame = body.CFrame + Vector3.new(0,0,0)})
local function onClicked()
if enabled.Value == false then
enabled.Value = true
print("Scene light enabled.")
light.Material = Enum.Material.Neon
emitter.Enabled = true
upTween:Play()
elseif enabled.Value == true then
enabled.Value = false
print("Scene light disabled.")
light.Material = Enum.Material.SmoothPlastic
emitter.Enabled = false
downTween:Play()
end
end
clickDetector.MouseClick:Connect(onClicked)
Is there a specialty weld script I need for use with vehicles?
Edit: Now the tween is broken entirely and the model snaps to the ground after launching the game, light will still enable/disable however.