Trying to make an open and close door but it gives me an error saying "Unable to cast to dictionary"
local door = game.Workspace.Door local TweenService = game:GetService("TweenService") local TweenStyle = TweenInfo.new(0.5,Enum.EasingStyle.Quad) local dooropen = (door.CFrame + Vector3.new(0, 10, 0)) local doorclose = (door.CFrame + Vector3.new(0, -10, 0)) local doortween = TweenService:Create(door,TweenStyle,doorclose) local closedoortween = TweenService:Create(door,TweenService,dooropen) script.Parent.ClickDetector.MouseClick:Connect(function() doortween:Play() wait(5) closedoortween:Play() end)
Does anyone know how to fix it? Edit: The error is on line 9
You need a dictionary to indicate the value of the given attribute. So change your code to this:
local door = game.Workspace.Door local TweenService = game:GetService("TweenService") local TweenStyle = TweenInfo.new(0.5,Enum.EasingStyle.Quad) local dooropen = {CFrame = door.CFrame * CFrame.new(10, 0, 0)} local doorclose = {CFrame = door.CFrame * CFrame.new(-10, 0, 0)} local doortween = TweenService:Create(door,TweenStyle,doorclose) local closedoortween = TweenService:Create(door,TweenStyle ,dooropen) script.Parent.ClickDetector.MouseClick:Connect(function() doortween:Play() wait(5) closedoortween:Play() end)