So i was making an obby and i wanted to do a moving part with tween service i did it and then it said "unable to cast dictionary"
wait(1) twee = game:GetService("TweenService") local part = script.Parent
local info = TweenInfo.new( 5, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, -1, true, 0 )
local create = { part.Position == Vector3.new(-194.115, 34.227, -1.536) }
local tweencreate = twee:Create(part,info,create)
tweencreate:Play()
Happy St. Patrick's Day!
I have a solution for you!
Inside the 'Create' table, you did part.Position, instead of part.Position, just do Position, and replace == with =.
e.g:
local create = { Position = Vector3.new(-194.115, 34.227, -1.536) }
I have decided to expand upon your script. I have a new-and-improved version!
local reachedGoal = false local OGPos = script.Parent.Position local GoalPos = workspace.Part2.Position -- Replace Part2 with the name of your part. local Tween = game:GetService("TweenService") local part = script.Parent local infotime = 5 local info = TweenInfo.new( infotime, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, true, 0 ) while wait(1) do if reachedGoal == false then local info = TweenInfo.new( 5, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, true, 0 ) local tweencreate = Tween:Create(part,info,{Position = GoalPos}) tweencreate:Play() tweencreate.Completed:Connect(function() reachedGoal = true print("Reached Second Position.") end) wait(infotime + 2.5) else local tweencreate = Tween:Create(part,info,{Position = OGPos}) tweencreate:Play() tweencreate.Completed:Connect(function() reachedGoal = false print("Reached First Position.") end) wait(infotime + 2.5) end end
LOTS to explain here, so time to begin.
I added a variable called 'reachedGoal' which is used later on. I added 2 position variables, our original position and our Part2 position. Then some extra variables, then a loop. This loop checks if reachedGoal is either true or false every second. If reachedGoal is false, then we continue. We get the info, then create the tween. It gets the part, info, and the Position. Since reachedGoal is false, we go to GoalPos (aka Part2's position). We paly the animation, and start a Completed function. The Completed function fires when the Tween is, well, completed! It switches reachedGoal to true, and then it fires the opposite code. It's basically the same code, just with some differences. Instead of GoalPos, it's OGPos.
Also, after both these functions, theres a wait(). This makes it wait the amount of time the tween is with the added 2.5 wait.
That's basically it, thanks for reading, and if you found this helpful, make sure you set this as 'solved'!