Unable to cast to Dictionary

Hello again, so I was trying to make a system where you can rotate your tower while trying to place it by pressing Q or R It works fine but I wanted to add animations to it so I used TweenService to do it but an error shows up saying what the title said how do I fix this?

RunService.RenderStepped:Connect(function()
	if TowerToSpawn then
		
		local Result = MouseRaycast({TowerToSpawn})
		
		for i, Borders in ipairs(workspace.Map.Towers:GetDescendants()) do
			if Borders:IsA("Part") and Borders.Name == "Border" then
				Borders.Transparency = 0.5
				CanPlace = false
			end
		end
		
		if Result and Result.Instance then
			
			if Result == "AllowedArea" or Result.Instance.Name == "AllowedArea" then
				CanPlace = true
				OutlineColor(Color3.fromRGB(255, 255, 255))
			else
				CanPlace = false
				OutlineColor(Color3.fromRGB(255, 0, 0))
			end
			local X = Result.Position.X
			local Y = Result.Position.Y + TowerToSpawn.Humanoid.HipHeight + (TowerToSpawn.PrimaryPart.Size.Y /2)
			local Z = Result.Position.Z
			
			local SpinInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
			
			local RotateAnimation = TweenService:Create(TowerToSpawn.PrimaryPart, SpinInfo, {CFrame.new(X, Y, Z) * CFrame.Angles(0, math.rad(Rotation), 0)})
			
			RotateAnimation:Play()
			SoundsFolder.Rotate:Play()
		end
	end
end)

in the goal array you have to specify what property you wanna change. It would have to be {CFrame = NewCFrameHere} not {NewCFrameHere}

This isn’t a dictionary…

The easiest fix for that is {CFrame = CFrame.new(X, Y, Z) * CFrame.Angles(0, math.rad(Rotation), 0)}. The final parameter of TweenService:Create() is expected to be a dictionary, not an array as it is not smart enough to figure out itself where to assign this value to.

Ty so much, It somehow gives the placeholder tower floaty(ish) moving animation but I kinda like it soo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.