I'm trying to make a door sliding script that uses tween service to move the door. But when I do use it, the output says it's unable to cast to dictionary. How could I fix this? Thanks.
local goal = script.Parent.Door.Position + Vector3.new(1,0,0) local function DoorAnim () local TweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new(5) local tween = TweenService:Create(script.Parent.Door, tweenInfo, goal) tween:Play() end script.Parent.Model.Part1.SurfaceGui.TextButton.MouseButton1Down:Connect(function() DoorAnim() end)
The problem is that your goal
variable is a Vector3 type. It should be a dictionary, with the keys being the properties you want to change and the values being the new values of those properties.
local goal = { Position = script.Parent.Door.Position + Vector3.new(1, 0, 0) } local function DoorAnim () local TweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new(5) local tween = TweenService:Create(script.Parent.Door, tweenInfo, goal) tween:Play() end script.Parent.Model.Part1.SurfaceGui.TextButton.MouseButton1Down:Connect(function() DoorAnim() end)
Hope this helps! :)