Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I fix this script? (TweenService and CFrame)

Hello, I am very beginning on scripting, I am trying to move unions via TweenService, This model will use on a train, It appears to be an error and I don't understand how to fix it.

The Model is that:

Model> Control (NumberValue) Door 1(Model)> Open(script) <-the broken one LDoor(union) LW(union) RDoor(union) RW(union)

The content of Open(Script)

while true do
	wait()
	
if script.Parent.Parent.Control.Value == 1 then
		
local TweenService = game:GetService("TweenService")

local Target1 = script.Parent.LDoor

local Target2 = script.Parent.LW
		
local Target3 = script.Parent.RDoor

local Target4 = script.Parent.RW
		
local TweenProperties1 = TweenInfo.new(0.5,Enum.EasingStyle.Linear)

local TweenProperties2 = TweenInfo.new(4,Enum.EasingStyle.Linear)
		
local TweenData1 = {CFrame = CFrame * CFrame.new(0,0,0.2)} -- add 0.2 studs in Z
		
local TweenData2L = {CFrame = CFrame * CFrame.new(4,0,0)} -- add 4 studs in X
		
local TweenData2R = {CFrame = CFrame * CFrame.new(-4,0,0)} -- minus 4 studs in X
		
local T = TweenService:Create(Target4, TweenProperties1, TweenData1):Play()

TweenService:Create(Target1, TweenProperties1, TweenData1):Play()
TweenService:Create(Target2, TweenProperties1, TweenData1):Play()		
TweenService:Create(Target3, TweenProperties1, TweenData1):Play()		
TweenService:Create(Target4, TweenProperties1, TweenData1):Play()
wait(0.5)
TweenService:Create(Target1, TweenProperties2, TweenData2L):Play()
TweenService:Create(Target2, TweenProperties2, TweenData2L):Play()		
TweenService:Create(Target3, TweenProperties2, TweenData2R):Play()		
TweenService:Create(Target4, TweenProperties2, TweenData2R):Play()

wait(1)	
script.Parent.Parent.Control.Value = 2 
T.Completed:Connect(function()
			print("Open Complete ")
		end)
	
	end
end

The error message is:Workspace.Model.Door 1.Open:20: invalid argument #1 (CFrame expected, got table)

I am unfamiliar with scripting with CFrame, so I'm sorry for the messy code.

1 answer

✓ Accepted answer

CFrame in tweens within' the tweendata table is an identifier. Instead, use

{CFrame = Target1.CFrame * CFrame.new(0,0,0)}

Have fun!

2 comments

0

ballers

0

It works, Big Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.